From 6057e932085db67ccfe52c276332f8c8ab8a8817 Mon Sep 17 00:00:00 2001 From: dadepo Date: Wed, 6 Jul 2022 17:05:38 +0200 Subject: [PATCH] Updated code example that has since diverged from implementation (#133) * updated code example that has since diverged from implementation * using default export in example in readme. --- README.md | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6fe5652..2e6f292 100644 --- a/README.md +++ b/README.md @@ -22,24 +22,22 @@ yarn add @chainsafe/bls @chainsafe/blst By default, native bindings will be used if in NodeJS and they are installed. A WASM implementation ("herumi") is used as a fallback in case any error occurs. ```ts -import {SecretKey, secretKeyToPublicKey, sign, verify} from "@chainsafe/bls"; +import bls from "@chainsafe/bls"; (async () => { - await init("herumi"); + // class-based interface + const secretKey = bls.SecretKey.fromKeygen(); + const publicKey = secretKey.toPublicKey(); + const message = new Uint8Array(32); - // class-based interface - const secretKey = SecretKey.fromKeygen(); - const publicKey = secretKey.toPublicKey(); - const message = new Uint8Array(32); + const signature = secretKey.sign(message); + console.log("Is valid: ", signature.verify(publicKey, message)); - const signature = secretKey.sign(message); - console.log("Is valid: ", signature.verify(publicKey, message)); - - // functional interface - const sk = secretKey.toBytes(); - const pk = secretKeyToPublicKey(sk); - const sig = sign(sk, message); - console.log("Is valid: ", verify(pk, message, sig)); + // functional interface + const sk = secretKey.toBytes(); + const pk = bls.secretKeyToPublicKey(sk); + const sig = bls.sign(sk, message); + console.log("Is valid: ", bls.verify(pk, message, sig)); })(); ```