Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nitro-neal committed Aug 20, 2024
1 parent 3090298 commit 1fead60
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Ed25519Verifier : Verifier {
private val rustCoreVerifier: RustCoreEd25519Verifier

constructor(privateKey: Jwk) {
this.rustCoreVerifier = RustCoreEd25519Verifier(privateKey)
this.rustCoreVerifier = RustCoreEd25519Verifier(privateKey.rustCoreJwkData)
}

private constructor(rustCoreVerifier: RustCoreEd25519Verifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package web5.sdk.crypto.verifiers
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Assertions.assertFalse
import web5.sdk.crypto.keys.Jwk
import web5.sdk.crypto.signers.Ed25519Signer
import web5.sdk.rust.ed25519GeneratorGenerate as rustCoreEd25519GeneratorGenerate

Expand All @@ -11,12 +12,12 @@ class Ed25519VerifierTest {
@Test
fun `test verifier with valid signature`() {
val privateJwk = rustCoreEd25519GeneratorGenerate()
val ed25519Signer = Ed25519Signer(privateJwk)
val ed25519Signer = Ed25519Signer(Jwk.fromRustCoreJwkData(privateJwk))

val message = "abc".toByteArray()
val signature = ed25519Signer.sign(message)

val ed25519Verifier = Ed25519Verifier(privateJwk)
val ed25519Verifier = Ed25519Verifier(Jwk.fromRustCoreJwkData(privateJwk))
val isValid = ed25519Verifier.verify(message, signature)

assertTrue(isValid, "Signature should be valid")
Expand All @@ -25,14 +26,14 @@ class Ed25519VerifierTest {
@Test
fun `test verifier with invalid signature`() {
val privateJwk = rustCoreEd25519GeneratorGenerate()
val ed25519Signer = Ed25519Signer(privateJwk)
val ed25519Signer = Ed25519Signer(Jwk.fromRustCoreJwkData(privateJwk))

val message = "abc".toByteArray()
val signature = ed25519Signer.sign(message)

val modifiedMessage = "abcd".toByteArray()

val ed25519Verifier = Ed25519Verifier(privateJwk)
val ed25519Verifier = Ed25519Verifier(Jwk.fromRustCoreJwkData(privateJwk))
val isValid = ed25519Verifier.verify(modifiedMessage, signature)

assertFalse(isValid, "Signature should be invalid")
Expand Down

0 comments on commit 1fead60

Please sign in to comment.