add verify.go
This commit is contained in:
parent
5d649c992f
commit
5a37f8db1f
1 changed files with 53 additions and 0 deletions
53
verify.go
Normal file
53
verify.go
Normal file
|
@ -0,0 +1,53 @@
|
|||
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)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue