Documentation ¶
Index ¶
- Variables
- func PrivateKeyTo(key *PrivateKey) []byte
- func PublicKeyTo(key *PublicKey) []byte
- func Sign(rand io.Reader, priv *PrivateKey, h Hasher, data []byte, useISO14888_3 bool) (sig []byte, err error)
- func SignBytes(rand io.Reader, priv *PrivateKey, h Hasher, data []byte, useISO14888_3 bool) (sig []byte, err error)
- func SignToRS(rand io.Reader, priv *PrivateKey, hashFunc Hasher, msg []byte, ...) (r, s *big.Int, err error)
- func Verify(pub *PublicKey, h Hasher, data, sig []byte, useISO14888_3 bool) bool
- func VerifyBytes(pub *PublicKey, h Hasher, data, sig []byte, useISO14888_3 bool) bool
- func VerifyWithRS(pub *PublicKey, hashFunc Hasher, data []byte, r, s *big.Int, ...) bool
- type Hasher
- type PrivateKey
- type PublicKey
- type SignerOpts
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Sign ¶
func Sign(rand io.Reader, priv *PrivateKey, h Hasher, data []byte, useISO14888_3 bool) (sig []byte, err error)
Sign data returns the ASN.1 encoded signature.
func SignBytes ¶
func SignBytes(rand io.Reader, priv *PrivateKey, h Hasher, data []byte, useISO14888_3 bool) (sig []byte, err error)
Sign data returns the Bytes encoded signature.
func SignToRS ¶
func SignToRS(rand io.Reader, priv *PrivateKey, hashFunc Hasher, msg []byte, useISO14888_3 bool) (r, s *big.Int, err error)
*| IUF - EC-RDSA signature *| *| UF 1. Compute h = H(m) *| F 2. Get a random value k in ]0,q[ *| F 3. Compute W = (W_x,W_y) = kG *| F 4. Compute r = W_x mod q *| F 5. If r is 0, restart the process at step 2. *| F 6. Compute e = OS2I(h) mod q. If e is 0, set e to 1. *| NOTE: here, ISO/IEC 14888-3 and RFCs differ in the way e treated. *| e = OS2I(h) for ISO/IEC 14888-3, or e = OS2I(reversed(h)) when endianness of h *| is reversed for RFCs. *| F 7. Compute s = (rx + ke) mod q *| F 8. If s is 0, restart the process at step 2. *| F 11. Return (r,s) *
func Verify ¶
Verify verifies the ASN.1 encoded signature, sig, M, of hash using the public key, pub. Its return value records whether the signature is valid.
func VerifyBytes ¶
Verify verifies the Bytes encoded signature
func VerifyWithRS ¶
func VerifyWithRS(pub *PublicKey, hashFunc Hasher, data []byte, r, s *big.Int, useISO14888_3 bool) bool
*| IUF - EC-RDSA verification *| *| UF 1. Check that r and s are both in ]0,q[ *| F 2. Compute h = H(m) *| F 3. Compute e = OS2I(h)^-1 mod q *| NOTE: here, ISO/IEC 14888-3 and RFCs differ in the way e treated. *| e = OS2I(h) for ISO/IEC 14888-3, or e = OS2I(reversed(h)) when endianness of h *| is reversed for RFCs. *| F 4. Compute u = es mod q *| F 5. Compute v = -er mod q *| F 6. Compute W' = uG + vY = (W'_x, W'_y) *| F 7. Compute r' = W'_x mod q *| F 8. Check r and r' are the same *
Types ¶
type PrivateKey ¶
ec-gdsa PrivateKey
func GenerateKey ¶
Generate the PrivateKey
func NewPrivateKey ¶
func NewPrivateKey(curve elliptic.Curve, k []byte) (*PrivateKey, error)
New a PrivateKey from privatekey data
func (*PrivateKey) Equal ¶
func (priv *PrivateKey) Equal(x crypto.PrivateKey) bool
Equal reports whether pub and x have the same value.
func (*PrivateKey) Public ¶
func (priv *PrivateKey) Public() crypto.PublicKey
Public returns the public key corresponding to priv.
func (*PrivateKey) Sign ¶
func (priv *PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) ([]byte, error)
crypto.Signer
type PublicKey ¶
ec-gdsa PublicKey
func NewPublicKey ¶
根据公钥明文初始化公钥 New a PublicKey from publicKey data
type SignerOpts ¶
SignerOpts contains options for creating and verifying EC-GDSA signatures.
func (*SignerOpts) GetHash ¶
func (opts *SignerOpts) GetHash() Hasher
GetHash returns func() hash.Hash
func (*SignerOpts) GetUseISO14888_3 ¶
func (opts *SignerOpts) GetUseISO14888_3() bool
GetUseISO14888_3 returns bool
func (*SignerOpts) HashFunc ¶
func (opts *SignerOpts) HashFunc() crypto.Hash
HashFunc returns opts.Hash