-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use @noble/curves instead of @noble/ed25519 (#47)
- Loading branch information
1 parent
5f2a0e7
commit 9ca68e2
Showing
6 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@metaplex-foundation/umi-eddsa-web3js': patch | ||
--- | ||
|
||
Use @noble/curves instead of @noble/ed25519 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,38 @@ | ||
import { isPublicKey, utf8 } from '@metaplex-foundation/umi'; | ||
import test from 'ava'; | ||
import { web3JsEddsa } from '../src'; | ||
import { createWeb3JsEddsa } from '../src'; | ||
|
||
test('example test', async (t) => { | ||
t.is(typeof web3JsEddsa, 'function'); | ||
test('it can create a new private key', async (t) => { | ||
// Given an EDDSA interface. | ||
const eddsa = createWeb3JsEddsa(); | ||
|
||
// When we generate a new keypair. | ||
const keypair = eddsa.generateKeypair(); | ||
|
||
// Then the public key is valid. | ||
t.true(isPublicKey(keypair.publicKey)); | ||
t.true(eddsa.isOnCurve(keypair.publicKey)); | ||
|
||
// And the secret key is valid. | ||
t.true( | ||
typeof keypair.secretKey === 'object' && | ||
typeof keypair.secretKey.BYTES_PER_ELEMENT === 'number' && | ||
typeof keypair.secretKey.length === 'number' && | ||
keypair.secretKey.BYTES_PER_ELEMENT === 1 && | ||
keypair.secretKey.length === 64 | ||
); | ||
}); | ||
|
||
test('it can sign and verify messages', async (t) => { | ||
// Given a keypair. | ||
const eddsa = createWeb3JsEddsa(); | ||
const keypair = eddsa.generateKeypair(); | ||
|
||
// When that keypair signs a message and then verifies it. | ||
const message = utf8.serialize('Hello world!'); | ||
const signature = eddsa.sign(message, keypair); | ||
const verified = eddsa.verify(message, signature, keypair.publicKey); | ||
|
||
// Then we expect the signature to be valid. | ||
t.true(verified); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.