-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
doc.go
35 lines (28 loc) · 941 Bytes
/
doc.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
// Package secp256r1 implements Cosmos-SDK compatible ECDSA public and private key. The keys
// can be protobuf serialized and packed in Any.
package secp256r1
import (
"crypto/elliptic"
"fmt"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
)
const (
// fieldSize is the curve domain size.
fieldSize = 32
pubKeySize = fieldSize + 1
name = "secp256r1"
)
var secp256r1 elliptic.Curve
func init() {
secp256r1 = elliptic.P256()
// pubKeySize is ceil of field bit size + 1 for the sign
expected := (secp256r1.Params().BitSize + 7) / 8
if expected != fieldSize {
panic(fmt.Sprintf("Wrong secp256r1 curve fieldSize=%d, expecting=%d", fieldSize, expected))
}
}
// RegisterInterfaces adds secp256r1 PubKey to pubkey registry
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &PubKey{})
}