Coder Social home page Coder Social logo

deno support about noble-ed25519 HOT 9 CLOSED

paulmillr avatar paulmillr commented on May 21, 2024
deno support

from noble-ed25519.

Comments (9)

paulmillr avatar paulmillr commented on May 21, 2024

it should work, but it seems like we need to fix it

from noble-ed25519.

pgg avatar pgg commented on May 21, 2024
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.

christianbundy avatar christianbundy commented on May 21, 2024

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.

christianbundy avatar christianbundy commented on May 21, 2024

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.

paulmillr avatar paulmillr commented on May 21, 2024
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.

christianbundy avatar christianbundy commented on May 21, 2024

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.

paulmillr avatar paulmillr commented on May 21, 2024

yeah, you should use official modules @ deno.land

from noble-ed25519.

paulmillr avatar paulmillr commented on May 21, 2024

curl gives us:

content-type: application/typescript; charset=utf-8 for deno
Content-Type: text/plain; charset=utf-8 for gh

from noble-ed25519.

christianbundy avatar christianbundy commented on May 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.