Comments (9)
it should work, but it seems like we need to fix it
from noble-ed25519.
import * as ed from 'https://raw.githubusercontent.com/paulmillr/noble-ed25519/0.7.0/index.ts';
const PRIVATE_KEY = ed.utils.randomPrivateKey();
const HASH_MESSAGE = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef';
const publicKey = await ed.getPublicKey(PRIVATE_KEY);
const signature = await ed.sign(HASH_MESSAGE, PRIVATE_KEY);
const isMessageSigned = await ed.verify(signature, HASH_MESSAGE, publicKey);
console.info(publicKey, signature, isMessageSigned);
from noble-ed25519.
I got Deno working with this library, but I couldn't figure out how to run the tests easily since they depend on Node.js for opening files and such. Maybe someone else can take it to the finish line?
https://github.com/christianbundy/noble-ed25519/tree/deno
(No guarantees that I haven't broken anything, use at your own risk.)
from noble-ed25519.
Thanks for the fix! I'm still seeing the old problems, could you help me figure out what I'm doing wrong?
$ deno --version
deno 1.0.0
v8 8.4.300
typescript 3.9.2
$ deno run https://raw.githubusercontent.com/paulmillr/noble-ed25519/master/mod.ts
Compile https://raw.githubusercontent.com/paulmillr/noble-ed25519/master/mod.ts
error: TS2531 [ERROR]: Object is possibly 'null'.
const buffer = await window.crypto.subtle.digest('SHA-512', message.buffer);
~~~~~~~~~~~~~~~~~~~~
at https://raw.githubusercontent.com/paulmillr/noble-ed25519/master/index.ts:514:26
TS2580 [ERROR]: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i @types/node`.
} else if (typeof process === 'object' && 'node' in process.versions) {
~~~~~~~
at https://raw.githubusercontent.com/paulmillr/noble-ed25519/master/index.ts:520:19
TS2580 [ERROR]: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i @types/node`.
} else if (typeof process === 'object' && 'node' in process.versions) {
~~~~~~~
at https://raw.githubusercontent.com/paulmillr/noble-ed25519/master/index.ts:520:53
TS2580 [ERROR]: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i @types/node`.
const { createHash, randomBytes } = require('crypto');
~~~~~~~
at https://raw.githubusercontent.com/paulmillr/noble-ed25519/master/index.ts:521:39
Found 4 errors.
from noble-ed25519.
test ❯ cat a.ts
import * as ed from 'https://deno.land/x/ed25519/mod.ts';
const PRIVATE_KEY = ed.utils.randomPrivateKey(); // 32-byte Uint8Array or string.
const HASH_MESSAGE = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef';
const publicKey = await ed.getPublicKey(PRIVATE_KEY);
console.log(publicKey)
test ❯ deno run a.ts
Uint8Array(32) [
228, 5, 212, 192, 244, 83, 151, 120,
238, 29, 77, 106, 177, 250, 129, 255,
105, 61, 194, 34, 81, 101, 98, 11,
180, 33, 220, 255, 179, 158, 17, 130
]
from noble-ed25519.
Maybe a silly question (sorry), but what's the difference between running from github.com vs deno.land?
$ deno run https://deno.land/x/ed25519/mod.ts
$ echo "no errors above"
no errors above
$ deno run https://raw.githubusercontent.com/paulmillr/noble-ed25519/master/mod.ts
Compile https://raw.githubusercontent.com/paulmillr/noble-ed25519/master/mod.ts
error: TS2531 [ERROR]: Object is possibly 'null'.
const buffer = await window.crypto.subtle.digest('SHA-512', message.buffer);
~~~~~~~~~~~~~~~~~~~~
at https://raw.githubusercontent.com/paulmillr/noble-ed25519/master/index.ts:514:26
TS2580 [ERROR]: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i @types/node`.
} else if (typeof process === 'object' && 'node' in process.versions) {
~~~~~~~
at https://raw.githubusercontent.com/paulmillr/noble-ed25519/master/index.ts:520:19
TS2580 [ERROR]: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i @types/node`.
} else if (typeof process === 'object' && 'node' in process.versions) {
~~~~~~~
at https://raw.githubusercontent.com/paulmillr/noble-ed25519/master/index.ts:520:53
TS2580 [ERROR]: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i @types/node`.
const { createHash, randomBytes } = require('crypto');
~~~~~~~
at https://raw.githubusercontent.com/paulmillr/noble-ed25519/master/index.ts:521:39
Found 4 errors.
from noble-ed25519.
yeah, you should use official modules @ deno.land
from noble-ed25519.
curl gives us:
content-type: application/typescript; charset=utf-8
for deno
Content-Type: text/plain; charset=utf-8
for gh
from noble-ed25519.
Looks like rm -rf ~/.cache/deno
did the trick. I don't know what deno.land is doing to circumvent it, but I'll use permalinks when pulling from GH in the future. Thanks for your help!
from noble-ed25519.
Related Issues (20)
- Signing using Extened Private Key HOT 3
- The package ( @noble/ed25519 ) is throwing some math errors in production works fine in local HOT 2
- Compatibility with libsodium generated keys HOT 1
- Wrong signature with version > 1.60
- Deno import error HOT 5
- Can someone help me with the getSharedSecret function? HOT 1
- 64byte (extended) ed25519 private keys HOT 6
- ed.utils.hexToBytes not mentioned in README HOT 1
- synchronous `getSharedSecret()`
- What are your sources for the algorithm? HOT 5
- making API consistent
- replacement for getSharedSecret HOT 6
- v2 throws error in FF when bundled with parcel HOT 2
- Jest gives an error: "SyntaxError: Unexpected token export" HOT 2
- How to create hybrid NPM package for Node.js and bundlers? HOT 3
- Error: crypto.getRandomValues must be defined HOT 5
- React Native compatibility issue HOT 7
- const err = (m = '') => { throw new Error(m); }; // error helper, messes-up stack trace HOT 2
- Random PRNG - how secure is it? HOT 4
- Can not make it generate or verify the signature HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from noble-ed25519.