Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: verify message and verify transaction #14

Merged
merged 1 commit into from
May 31, 2024

Conversation

wuuuk
Copy link
Contributor

@wuuuk wuuuk commented Dec 8, 2023

Fixes #12

Changes:

  • Move signer.IntentScope to constant package
  • Move the intent function in the signer to the models package
  • Signer: add transaction signature and message signature of sui protocol
  • Models: add signature verification of transaction and message

Examples:

  • Sign message
func main() {
	user, _ := NewSignertWithMnemonic("${MNEMONIC_STRING}")

	// sign message
	message := "Welcome to SUI!"
	signature, _ := user.SignPersonalMessage(message)

	// verify message
	signer, pass, err := models.VerifyPersonalMessage(message, signature.Signature)
	...
}
  • Sign transaction
func main() {
	user, _ := NewSignertWithMnemonic("${MNEMONIC_STRING}")
	suiApi := sui.NewSuiClient("${RPC_URL}")

	// move call
	txn, _ := suiApi.MoveCall(context.Background(), models.MoveCallRequest{})

	// sign transaction
	signature, _ := user.SignTransaction(txn.TxBytes)

	// verify transaction
	signer, pass, err := models.VerifyTransaction(txn.TxBytes, signature.Signature)
	// ...
}

@JaydenLink JaydenLink merged commit 4617c99 into block-vision:main May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

signature verification
2 participants