format code

This commit is contained in:
doesnm 2024-09-08 16:28:55 +03:00
parent ec36706d6c
commit d47ce356df
No known key found for this signature in database

View file

@ -1,54 +1,54 @@
package main package main
import ( import (
"encoding/json" "crypto/ed25519"
"fmt" "crypto/sha256"
"github.com/writeas/activityserve" "encoding/json"
"crypto/sha256" "fmt"
"crypto/ed25519" "github.com/btcsuite/btcutil/base58"
"github.com/btcsuite/btcutil/base58" "github.com/writeas/activityserve"
//"crypto" // "crypto"
) )
func main(){ func main() {
actor, err := activityserve.LoadActor("ED4xVR2hw6frfBNFJataKYZn58WnaotS8d8WKg4H5rfC") actor, err := activityserve.LoadActor("ED4xVR2hw6frfBNFJataKYZn58WnaotS8d8WKg4H5rfC")
if err != nil { if err != nil {
fmt.Println(err)
}
activityserve.Setup("config.ini",false)
//rActor, err := activityserve.NewRemoteActor(actor, "https://mitra.social/.well-known/apgateway/did:key:z6MknVmyPtQmD2SaGnqyGgTVEqfqkkJJnY3YVKBmbzSUNCcX/actor")
rActor, err := activityserve.NewRemoteActor(actor,"http://localhost:8000/silverpill.json")
if err != nil {
fmt.Println(err)
}
ractorRaw := rActor.GetRaw()
proof := ractorRaw["proof"].(map[string]interface{})
delete(ractorRaw,"proof")
ractorJson,err := json.Marshal(ractorRaw)
if err != nil {
fmt.Println(err)
}
ractorJsonString := string(ractorJson)
hashActor := sha256.New()
hashActor.Write([]byte(ractorJsonString))
hashActorRes := hashActor.Sum(nil)
verificationMethod := proof["verificationMethod"].(string)
proofValue := proof["proofValue"].(string)[0:]
proofValueDecoded := base58.Decode(proofValue)
proofValueStripped := proofValueDecoded[2:]
publicKeyDecoded := base58.Decode(verificationMethod[9:])
publicKeyDecoded32 := publicKeyDecoded[2:]
//publicKey := ed25519.PublicKey(publicKeyDecoded32)
//fmt.Println(publicKey)
fmt.Println(publicKeyDecoded32)
fmt.Println(hashActorRes)
fmt.Println(proofValueStripped)
err = ed25519.VerifyWithOptions(publicKeyDecoded32, hashActorRes, proofValueStripped, &ed25519.Options{
Hash: 0,
});
if err != nil {
fmt.Println(err) fmt.Println(err)
} }
activityserve.Setup("config.ini", false)
// rActor, err := activityserve.NewRemoteActor(actor, "https://mitra.social/.well-known/apgateway/did:key:z6MknVmyPtQmD2SaGnqyGgTVEqfqkkJJnY3YVKBmbzSUNCcX/actor")
rActor, err := activityserve.NewRemoteActor(actor, "http://localhost:8000/silverpill.json")
if err != nil {
fmt.Println(err)
}
ractorRaw := rActor.GetRaw()
proof := ractorRaw["proof"].(map[string]interface{})
delete(ractorRaw, "proof")
ractorJson, err := json.Marshal(ractorRaw)
if err != nil {
fmt.Println(err)
}
ractorJsonString := string(ractorJson)
hashActor := sha256.New()
hashActor.Write([]byte(ractorJsonString))
hashActorRes := hashActor.Sum(nil)
verificationMethod := proof["verificationMethod"].(string)
proofValue := proof["proofValue"].(string)[0:]
proofValueDecoded := base58.Decode(proofValue)
proofValueStripped := proofValueDecoded[2:]
publicKeyDecoded := base58.Decode(verificationMethod[9:])
publicKeyDecoded32 := publicKeyDecoded[2:]
// publicKey := ed25519.PublicKey(publicKeyDecoded32)
// fmt.Println(publicKey)
fmt.Println(publicKeyDecoded32)
fmt.Println(hashActorRes)
fmt.Println(proofValueStripped)
err = ed25519.VerifyWithOptions(publicKeyDecoded32, hashActorRes, proofValueStripped, &ed25519.Options{
Hash: 0,
})
if err != nil {
fmt.Println(err)
}
} }