this repo has no description
0
fork

Configure Feed

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

crypto: duplicate P-256 pub key not needed

+6 -19
+6 -19
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 - pubP256ecdh ecdh.PublicKey 26 25 pubP256 ecdsa.PublicKey 27 26 } 28 27 ··· 90 89 if !ok { 91 90 return nil, fmt.Errorf("unexpected internal error casting P-256 ecdsa public key") 92 91 } 93 - pkECDH, err := pkECDSA.ECDH() 94 - if err != nil { 95 - return nil, fmt.Errorf("unexpected internal error converting P-256 key from ecdsa to ecdh: %w", err) 96 - } 97 - return &PublicKeyP256{pubP256: *pkECDSA, pubP256ecdh: *pkECDH}, nil 92 + return &PublicKeyP256{pubP256: *pkECDSA}, nil 98 93 } 99 94 100 95 // First hashes the raw bytes, then signs the digest, returning a binary signature. ··· 134 129 X: x, 135 130 Y: y, 136 131 } 137 - pubECDH, err := pubECDSA.ECDH() 138 - pub := PublicKeyP256{pubP256: *pubECDSA, pubP256ecdh: *pubECDH} 139 - if err != nil { 140 - return nil, fmt.Errorf("unexpected internal error converting P-256 x509 key from ecdsa to ecdh: %w", err) 141 - } 142 - err = pub.checkCurve() 132 + pub := PublicKeyP256{pubP256: *pubECDSA} 133 + err := pub.checkCurve() 143 134 if err != nil { 144 135 return nil, err 145 136 } ··· 163 154 X: x, 164 155 Y: y, 165 156 } 166 - pubECDH, err := pubECDSA.ECDH() 167 - pub := PublicKeyP256{pubP256: *pubECDSA, pubP256ecdh: *pubECDH} 168 - if err != nil { 169 - return nil, fmt.Errorf("unexpected internal error converting P-256 x509 key from ecdsa to ecdh: %w", err) 170 - } 171 - err = pub.checkCurve() 157 + pub := PublicKeyP256{pubP256: *pubECDSA} 158 + err := pub.checkCurve() 172 159 if err != nil { 173 160 return nil, err 174 161 } ··· 193 180 194 181 // Serializes the key in to "uncompressed" binary format. 195 182 func (k *PublicKeyP256) UncompressedBytes() []byte { 196 - return k.pubP256ecdh.Bytes() 183 + return elliptic.Marshal(k.pubP256.Curve, k.pubP256.X, k.pubP256.Y) 197 184 } 198 185 199 186 // Serializes the key in to "compressed" binary format.