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

Replace noble-ed25519 with tweetnacl #277

Merged
merged 6 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### v0.28.1

- Switch from noble-ed25519 to tweetnacl. Tweetnacl has been audited and can be used in a wider range of environments.

### v0.28.0

- Added the `fs.addPublicExchangeKey()` function which adds the public exchange key of that domain/browser/device to your filesystem at `/public/.well-known/exchange/DID_KEY`. Along with the `fs.hasPublicExchangeKey()` to check if it's there.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webnative",
"version": "0.28.0",
"version": "0.28.1",
"description": "Fission Webnative SDK",
"keywords": [
"WebCrypto",
Expand Down Expand Up @@ -99,8 +99,8 @@
"keystore-idb": "0.15.0",
"localforage": "^1.9.0",
"multiformats": "^9.0.0",
"noble-ed25519": "^1.2.4",
"throttle-debounce": "^3.0.1",
"tweetnacl": "^0.14.5",
"uint8arrays": "^2.1.7"
},
"resolutions": {
Expand Down
2 changes: 1 addition & 1 deletion src/common/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = "0.28.0"
export const VERSION = "0.28.1"
4 changes: 2 additions & 2 deletions src/crypto/browser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ed25519 from "noble-ed25519"
import tweetnacl from "tweetnacl"
import rsaOperations from "keystore-idb/rsa/index.js"
import utils from "keystore-idb/utils.js"
import aes from "keystore-idb/aes/index.js"
Expand Down Expand Up @@ -65,7 +65,7 @@ export const rsaVerify = (message: Uint8Array, signature: Uint8Array, publicKey:
}

export const ed25519Verify = (message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): Promise<boolean> => {
return ed25519.verify(signature, message, publicKey)
return new Promise(resolve => resolve(tweetnacl.sign.detached.verify(message, signature, publicKey)))
}

export const ksPublicExchangeKey = async (): Promise<string> => {
Expand Down
4 changes: 2 additions & 2 deletions src/setup/node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import crypto from "crypto"
import * as ed25519 from "noble-ed25519"
import tweetnacl from "tweetnacl"
import utils from "keystore-idb/utils.js"
import { CharSize, Config, CryptoSystem, KeyStore, KeyUse, Msg, PublicKey, SymmKeyLength } from "keystore-idb/types.js"
import config from "keystore-idb/config.js"
Expand Down Expand Up @@ -75,7 +75,7 @@ const rsaVerify = (message: Uint8Array, signature: Uint8Array, publicKey: Uint8A
}

const ed25519Verify = (message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): Promise<boolean> => {
return ed25519.verify(signature, message, publicKey)
return new Promise(resolve => resolve(tweetnacl.sign.detached.verify(message, signature, publicKey)))
}


Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"moduleResolution": "node",
"target": "ES2020",
"target": "ES2018",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

"module":"ESNext",
"lib": ["dom", "es2021"],
"strict": true,
Expand Down
Loading