this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: use PublicKey() instead of Public()

Based on double-checking the crypto/ecdsa stdlib interface, Public()
often returns a crypto.Public, and PublicKey() is used to return
specifically the package-local PublicKey type.

+11 -13
+1 -1
atproto/crypto/examples_test.go
··· 28 28 if err != nil { 29 29 panic("failed to generate key") 30 30 } 31 - pub, err := priv.Public() 31 + pub, err := priv.PublicKey() 32 32 if err != nil { 33 33 panic("failed to get public key") 34 34 }
+1 -1
atproto/crypto/k256.go
··· 73 73 } 74 74 75 75 // Outputs the [PublicKey] corresponding to this [PrivateKeyK256]; it will be a [PublicKeyK256]. 76 - func (k PrivateKeyK256) Public() (PublicKey, error) { 76 + func (k PrivateKeyK256) PublicKey() (PublicKey, error) { 77 77 pub := PublicKeyK256{pubK256: k.privK256.PublicKey()} 78 78 err := pub.ensureBytes() 79 79 if err != nil {
+1 -3
atproto/crypto/keys.go
··· 13 13 type PrivateKey interface { 14 14 Equal(other PrivateKey) bool 15 15 16 - // If necessary, pre-verifies that the public key curve point is valid and 17 - // will be possible to encode as bytes or a string later. 18 - Public() (PublicKey, error) 16 + PublicKey() (PublicKey, error) 19 17 20 18 // Hashes the raw bytes using SHA-256, then signs the digest bytes. 21 19 // Always returns a "low-S" signature (for elliptic curve systems where that is ambigious).
+5 -5
atproto/crypto/keys_test.go
··· 36 36 assert.Equal(privK256, privK256FromBytes) 37 37 38 38 // public key byte serialization (P-256) 39 - pubP256, err := privP256.Public() 39 + pubP256, err := privP256.PublicKey() 40 40 assert.NoError(err) 41 41 pubP256CompBytes := pubP256.Bytes() 42 42 pubP256FromCompBytes, err := ParsePublicBytesP256(pubP256CompBytes) ··· 50 50 51 51 both := []PrivateKey{privP256, privK256} 52 52 for _, priv := range both { 53 - pub, err := priv.Public() 53 + pub, err := priv.PublicKey() 54 54 assert.NoError(err) 55 55 56 56 // public key encoding ··· 93 93 94 94 both := []PrivateKey{privP256, privK256} 95 95 for _, priv := range both { 96 - pub, err := priv.Public() 96 + pub, err := priv.PublicKey() 97 97 assert.NoError(err) 98 98 99 99 _, err = rand.Read(msg) ··· 117 117 priv, err := GeneratePrivateKeyP256() 118 118 assert.NoError(err) 119 119 privBytes := priv.Bytes() 120 - pub, err := priv.Public() 120 + pub, err := priv.PublicKey() 121 121 assert.NoError(err) 122 122 sig, err := priv.HashAndSign([]byte("test-message")) 123 123 assert.NoError(err) ··· 135 135 priv, err := GeneratePrivateKeyK256() 136 136 assert.NoError(err) 137 137 privBytes := priv.Bytes() 138 - pub, err := priv.Public() 138 + pub, err := priv.PublicKey() 139 139 assert.NoError(err) 140 140 sig, err := priv.HashAndSign([]byte("test-message")) 141 141 assert.NoError(err)
+2 -2
atproto/crypto/p256.go
··· 22 22 23 23 // Implements the [PublicKey] interface for the NIST P-256 / secp256r1 / ES256 cryptographic curve. 24 24 type PublicKeyP256 struct { 25 - pubP256 ecdsa.PublicKey 25 + pubP256 ecdsa.PublicKey 26 26 } 27 27 28 28 var _ PrivateKey = (*PrivateKeyP256)(nil) ··· 84 84 } 85 85 86 86 // Outputs the [PublicKey] corresponding to this [PrivateKeyP256]; it will be a [PublicKeyP256]. 87 - func (k *PrivateKeyP256) Public() (PublicKey, error) { 87 + func (k *PrivateKeyP256) PublicKey() (PublicKey, error) { 88 88 pkECDSA, ok := k.privP256.Public().(*ecdsa.PublicKey) 89 89 if !ok { 90 90 return nil, fmt.Errorf("unexpected internal error casting P-256 ecdsa public key")
+1 -1
atproto/crypto/w3c_didkey_test.go
··· 82 82 if err != nil { 83 83 t.Fatal(err) 84 84 } 85 - kBytes, err := priv.Public() 85 + kBytes, err := priv.PublicKey() 86 86 if err != nil { 87 87 t.Fatal(err) 88 88 }