porting all github actions from bluesky-social/indigo to tangled CI
1
fork

Configure Feed

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

at main 47 lines 1.2 kB view raw
1package crypto 2 3import ( 4 "encoding/base64" 5 "fmt" 6) 7 8func ExamplePublicKey() { 9 pub, err := ParsePublicDIDKey("did:key:zDnaembgSGUhZULN2Caob4HLJPaxBh92N7rtH21TErzqf8HQo") 10 if err != nil { 11 panic("failed to parse did:key") 12 } 13 14 // parse existing base64 message and signature to raw bytes 15 msg, _ := base64.RawStdEncoding.DecodeString("oWVoZWxsb2V3b3JsZA") 16 sig, _ := base64.RawStdEncoding.DecodeString("2vZNsG3UKvvO/CDlrdvyZRISOFylinBh0Jupc6KcWoJWExHptCfduPleDbG3rko3YZnn9Lw0IjpixVmexJDegg") 17 if err = pub.HashAndVerify(msg, sig); err != nil { 18 fmt.Println("Verification Failed") 19 } else { 20 fmt.Println("Success!") 21 } 22 // Output: Success! 23} 24 25func ExamplePrivateKey() { 26 // create secure private key, and corresponding public key 27 priv, err := GeneratePrivateKeyK256() 28 if err != nil { 29 panic("failed to generate key") 30 } 31 pub, err := priv.PublicKey() 32 if err != nil { 33 panic("failed to get public key") 34 } 35 36 // sign a message 37 msg := []byte("hello world") 38 sig, _ := priv.HashAndSign(msg) 39 40 // verify the message 41 if err = pub.HashAndVerify(msg, sig); err != nil { 42 fmt.Println("Verification Failed") 43 } else { 44 fmt.Println("Success!") 45 } 46 // Output: Success! 47}