this repo has no description
0
fork

Configure Feed

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

crypto: just remove legacy/deprecated stuff

We can re-implement these internally in identity SDK, as needed.

+1 -74
+1 -4
atproto/crypto/examples_test.go
··· 10 10 if err != nil { 11 11 panic("failed to parse did:key") 12 12 } 13 - fmt.Println(pub.LegacyDidDocSuite()) 14 13 15 14 // parse existing base64 message and signature to raw bytes 16 15 msg, _ := base64.RawStdEncoding.DecodeString("oWVoZWxsb2V3b3JsZA") ··· 20 19 } else { 21 20 fmt.Println("Success!") 22 21 } 23 - // Output: 24 - // EcdsaSecp256r1VerificationKey2019 25 - // Success! 22 + // Output: Success! 26 23 } 27 24 28 25 func ExamplePrivateKey() {
-2
atproto/crypto/interop_fixtures_test.go
··· 74 74 75 75 // verify encodings 76 76 assert.Equal(pkDid, pkCompMultibase, "key equality") 77 - assert.Equal(row.DidDocSuite, pkDid.LegacyDidDocSuite()) 78 - assert.Equal(row.DidDocSuite, pkCompMultibase.LegacyDidDocSuite()) 79 77 assert.Equal(row.PublicKeyDid, pkDid.DidKey(), "did:key re-encoding") 80 78 81 79 // verify signatures
-16
atproto/crypto/k256.go
··· 183 183 return "z" + base58.Encode(kbytes) 184 184 } 185 185 186 - // Returns the DID cryptographic suite string which would be included in the `type` field of a `verificationMethod`. 187 - func (k *PublicKeyK256) LegacyDidDocSuite() string { 188 - // NOTE: this is not a W3C standard suite, and will probably be replaced with "Multikey" 189 - return "EcdsaSecp256k1VerificationKey2019" 190 - } 191 - 192 186 // Returns a did:key string encoding of the public key, as would be encoded in a DID PLC operation: 193 187 // 194 188 // - compressed / compacted binary representation ··· 199 193 func (k *PublicKeyK256) DidKey() string { 200 194 return "did:key:" + k.Multibase() 201 195 } 202 - 203 - // Returns multibase string encoding of the public key, as would be included in an older DID Document "verificationMethod" section: 204 - // 205 - // - non-compressed / non-compacted binary representation 206 - // - encode bytes with base58btc 207 - // - prefix "z" (lower-case) to indicate encoding 208 - func (k *PublicKeyK256) LegacyMultibase() string { 209 - kbytes := k.UncompressedBytes() 210 - return "z" + base58.Encode(kbytes) 211 - }
-32
atproto/crypto/keys.go
··· 64 64 // For curves with no compressed/uncompressed distinction, returns the same 65 65 // value as Bytes(). 66 66 UncompressedBytes() []byte 67 - 68 - // Outputs a DID cryptographic suite type name for this curve, as used in 69 - // some DID documents. 70 - // This method may be removed in the future. 71 - LegacyDidDocSuite() string 72 - 73 - // Helper to serialize in a format used in older DID documents: 74 - // uncompressed byte encoding, no multicodec prefix, base58btc multibase 75 - // string encoding ("z" prefix) 76 - // This method may be removed in the future. 77 - LegacyMultibase() string 78 67 } 79 68 80 69 // Parses a public key from multibase encoding, with multicodec indicating the key type. ··· 110 99 mb := strings.TrimPrefix(didKey, "did:key:") 111 100 return ParsePublicMultibase(mb) 112 101 } 113 - 114 - // Parses a public key in multibase encoding, as would be found in a older DID Document `verificationMethod` section: uncompressed binary, no multicodec prefix, and base58btc multibase string encoding. 115 - // 116 - // This function is likely to be deprecated and removed. 117 - func ParsePublicLegacyMultibase(encoded string, didDocSuite string) (PublicKey, error) { 118 - if len(encoded) < 2 || encoded[0] != 'z' { 119 - return nil, fmt.Errorf("crypto: not a multibase base58btc string") 120 - } 121 - data, err := base58.Decode(encoded[1:]) 122 - if err != nil { 123 - return nil, fmt.Errorf("crypto: not a multibase base58btc string") 124 - } 125 - switch didDocSuite { 126 - case "EcdsaSecp256r1VerificationKey2019": 127 - return ParsePublicUncompressedBytesP256(data) 128 - case "EcdsaSecp256k1VerificationKey2019": 129 - return ParsePublicUncompressedBytesK256(data) 130 - default: 131 - return nil, fmt.Errorf("unhandled legacy crypto suite: %s", didDocSuite) 132 - } 133 - }
-5
atproto/crypto/keys_test.go
··· 47 47 assert.NoError(err) 48 48 assert.True(pubP256.Equal(pubP256FromUncompBytes)) 49 49 50 - pubP256LegacyMultibaseString := pubP256.LegacyMultibase() 51 - pubP256LMB, err := ParsePublicLegacyMultibase(pubP256LegacyMultibaseString, "EcdsaSecp256r1VerificationKey2019") 52 - assert.NoError(err) 53 - assert.True(pubP256.Equal(pubP256LMB)) 54 - 55 50 both := []PrivateKey{privP256, privK256} 56 51 for _, priv := range both { 57 52 pub, err := priv.Public()
-15
atproto/crypto/p256.go
··· 240 240 return "z" + base58.Encode(kbytes) 241 241 } 242 242 243 - // Returns the DID cryptographic suite string which would be included in the `type` field of a `verificationMethod`. 244 - func (k *PublicKeyP256) LegacyDidDocSuite() string { 245 - return "EcdsaSecp256r1VerificationKey2019" 246 - } 247 - 248 243 // Returns a did:key string encoding of the public key, as would be encoded in a DID PLC operation: 249 244 // 250 245 // - compressed / compacted binary representation ··· 255 250 func (k *PublicKeyP256) DidKey() string { 256 251 return "did:key:" + k.Multibase() 257 252 } 258 - 259 - // Returns multibase string encoding of the public key, as would be included in an older DID Document "verificationMethod" section: 260 - // 261 - // - non-compressed / non-compacted binary representation 262 - // - encode bytes with base58btc 263 - // - prefix "z" (lower-case) to indicate encoding 264 - func (k *PublicKeyP256) LegacyMultibase() string { 265 - kbytes := k.UncompressedBytes() 266 - return "z" + base58.Encode(kbytes) 267 - }