github.com/Finschia/finschia-sdk@v0.48.1/crypto/keys/secp256r1/doc.go (about) 1 // Package secp256r1 implements Cosmos-SDK compatible ECDSA public and private key. The keys 2 // can be protobuf serialized and packed in Any. 3 package secp256r1 4 5 import ( 6 "crypto/elliptic" 7 "fmt" 8 9 codectypes "github.com/Finschia/finschia-sdk/codec/types" 10 cryptotypes "github.com/Finschia/finschia-sdk/crypto/types" 11 ) 12 13 const ( 14 // fieldSize is the curve domain size. 15 fieldSize = 32 16 pubKeySize = fieldSize + 1 17 18 name = "secp256r1" 19 ) 20 21 var secp256r1 elliptic.Curve 22 23 func init() { 24 secp256r1 = elliptic.P256() 25 // pubKeySize is ceil of field bit size + 1 for the sign 26 expected := (secp256r1.Params().BitSize + 7) / 8 27 if expected != fieldSize { 28 panic(fmt.Sprintf("Wrong secp256r1 curve fieldSize=%d, expecting=%d", fieldSize, expected)) 29 } 30 } 31 32 // RegisterInterfaces adds secp256r1 PubKey to pubkey registry 33 func RegisterInterfaces(registry codectypes.InterfaceRegistry) { 34 registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &PubKey{}) 35 }