Skip to content

Commit

Permalink
feat: task2 missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
navillanueva committed Feb 4, 2025
1 parent 2fc6d1a commit 1e7a0e5
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions verifyBLS/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
_ "embed"

"github.com/ethereum/go-ethereum/common"

bls "github.com/ava-labs/avalanchego/utils/crypto/bls"
)

const (
Expand Down Expand Up @@ -97,12 +99,27 @@ func verifySignatureBLS(accessibleState contract.AccessibleState, caller common.
return nil, remainingGas, err
}

// CUSTOM CODE STARTS HERE
_ = inputStruct // CUSTOM CODE OPERATES ON INPUT
// Convert the message string to bytes.
messageBytes := []byte(inputStruct.Message)

// Parse the signature from bytes.
sig, err := bls.SignatureFromBytes(inputStruct.Signature)
if err != nil {
return nil, remainingGas, fmt.Errorf("failed to parse signature: %w", err)
}

// Parse the public key from bytes.
pubKey, err := bls.PublicKeyFromCompressedBytes(inputStruct.PublicKey)
if err != nil {
return nil, remainingGas, fmt.Errorf("failed to parse public key: %w", err)
}

// Use the BLS package to verify the signature.
// This returns a boolean indicating whether the signature is valid.
verified := bls.Verify(pubKey, sig, messageBytes)

var output bool // CUSTOM CODE FOR AN OUTPUT
bls
packedOutput, err := PackVerifySignatureBLSOutput(output)
// Pack the boolean output.
packedOutput, err := PackVerifySignatureBLSOutput(verified)
if err != nil {
return nil, remainingGas, err
}
Expand Down

0 comments on commit 1e7a0e5

Please sign in to comment.