utils

package
v0.0.0-...-d9e9996 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package utils defines some crypto/signature utilities

Package utils file implements the Elliptic Curve Digital Signature Algorithm, as defined in FIPS 186-3.

This implementation derives the nonce from an AES-CTR CSPRNG keyed by ChopMD(256, SHA2-512(priv.D || entropy || hash)). The CSPRNG key is IRO by a result of Coron; the AES-CTR stream is IRO under standard assumptions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecrypt

func AESDecrypt(ct, key []byte) ([]byte, error)

AESDecrypt decrypt encrypted text to plaint text using key

func AESDecryptHex

func AESDecryptHex(ctHex string, key []byte) ([]byte, error)

AESDecryptHex decrypt base64-encoded encrypted text to plaint text using key

func AESEncrypt

func AESEncrypt(pt, key []byte) ([]byte, error)

AESEncrypt encrypt plaint text to encrypted text using key

func AESEncryptHex

func AESEncryptHex(pt, key []byte) (string, error)

AESEncryptHex encrypt plaint text to base64-encoded encrypted text using key

func GenerateKeyBySeed

func GenerateKeyBySeed(c elliptic.Curve, seed []byte) (*ecdsa.PrivateKey, error)

GenerateKeyBySeed generates a public and private key pair.

func MarshalECDSASignature

func MarshalECDSASignature(r, s *big.Int) ([]byte, error)

MarshalECDSASignature use DER-encoded ASN.1 octet standard to represent the signature 与比特币算法一样,基于DER-encoded ASN.1 octet标准,来表达使用椭圆曲线签名算法返回的结果

func MarshalPublicKey

func MarshalPublicKey(publicKey *ecdsa.PublicKey) []byte

MarshalPublicKey 将公钥序列化成byte数组

func UnmarshalECDSASignature

func UnmarshalECDSASignature(rawSig []byte) (*big.Int, *big.Int, error)

UnmarshalECDSASignature 从封装的签名中拿出原始签名

Types

type ECDSASignature

type ECDSASignature struct {
	R, S *big.Int
}

ECDSASignature is the structure for marshall signature

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL