-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsa.go
84 lines (63 loc) · 2.61 KB
/
dsa.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package bliss
import (
"io"
dcrcrypto "github.com/coolsnady/hcd/crypto"
"github.com/coolsnady/bliss/poly"
)
type DSA interface {
// ----------------------------------------------------------------------------
// Private keys
//
// NewPrivateKey instantiates a new private key for the given data
NewPrivateKey(s1, s2, a *poly.PolyArray) dcrcrypto.PrivateKey
// PrivKeyFromBytes calculates the public key from serialized bytes,
// and returns both it and the private key.
PrivKeyFromBytes(pk []byte) (dcrcrypto.PrivateKey, dcrcrypto.PublicKey)
// PrivKeyBytesLen returns the length of a serialized private key.
PrivKeyBytesLen() int
// ----------------------------------------------------------------------------
// Public keys
//
// NewPublicKey instantiates a new public key (point) for the given data.
NewPublicKey(a *poly.PolyArray) dcrcrypto.PublicKey
// ParsePubKey parses a serialized public key for the given
// curve and returns a public key.
ParsePubKey(pubKeyStr []byte) (dcrcrypto.PublicKey, error)
// PubKeyBytesLen returns the length of the default serialization
// method for a public key.
PubKeyBytesLen() int
// ----------------------------------------------------------------------------
// Signatures
//
// NewSignature instantiates a new signature
NewSignature(z1, z2 *poly.PolyArray, c []uint32) dcrcrypto.Signature
// ParseDERSignature parses a DER encoded signature .
// If the method doesn't support DER signatures, it
// just parses with the default method.
ParseDERSignature(sigStr []byte) (dcrcrypto.Signature, error)
// ParseSignature a default encoded signature
ParseSignature(sigStr []byte) (dcrcrypto.Signature, error)
// RecoverCompact recovers a public key from an encoded signature
// and message, then verifies the signature against the public
// key.
RecoverCompact(signature, hash []byte) (dcrcrypto.PublicKey, bool, error)
// ----------------------------------------------------------------------------
// Bliss
//
// GenerateKey generates a new private and public keypair from the
// given reader.
GenerateKey(rand io.Reader) (dcrcrypto.PrivateKey, dcrcrypto.PublicKey, error)
// Sign produces an Bliss signature using a private key and a message.
Sign(priv dcrcrypto.PrivateKey, hash []byte) (dcrcrypto.Signature, error)
// Verify verifies an Bliss signature against a given message and
// public key.
Verify(pub dcrcrypto.PublicKey, hash []byte, sig dcrcrypto.Signature) bool
}
const (
BSTypeBliss = 4
BlissVersion = 1
BlissPubKeyLen = 897
BlissPrivKeyLen = 385
)
// Secp256k1 is the secp256k1 curve and ECDSA system used in Bitcoin.
var Bliss = newBlissDSA()