54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"github.com/writeas/activityserve"
|
|
"crypto/sha256"
|
|
"crypto/ed25519"
|
|
"github.com/btcsuite/btcutil/base58"
|
|
//"crypto"
|
|
)
|
|
|
|
func main(){
|
|
actor, err := activityserve.LoadActor("ED4xVR2hw6frfBNFJataKYZn58WnaotS8d8WKg4H5rfC")
|
|
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)
|
|
}
|
|
}
|