diff --git a/CHANGELOG.fr.md b/CHANGELOG.fr.md index eda12cdfd60f499ab5bcf505ecec8c144735879b..dcc4889553f00bb238fa2f30c64c5e55ae949ccb 100644 --- a/CHANGELOG.fr.md +++ b/CHANGELOG.fr.md @@ -15,6 +15,10 @@ et ce projet adhère au [versionnage sémantique](https://semver.org/spec/v2.0.0 ## [Non-publié/Non-Stabilisé] (par [1000i100]) +## [Version 3.3.2] - 2022-09-30 (par [1000i100]) +### Corrections +- export de sha256 pour le rendre utilisable par les clients. + ## [Version 3.3.1] - 2022-09-30 (par [1000i100]) ### Corrections - suppression de crypto.isPubkey(pubkey) qui ne validait qu'à partir d'une regex contrairement à crypto.isPubKey(pubKey) qui effectue les vérifications implémentées dans la v3.3.0 @@ -90,8 +94,9 @@ et ce projet adhère au [versionnage sémantique](https://semver.org/spec/v2.0.0 - intégration des librairies de crypto nécessaires - calcul de la clef publique correspondant à chaque combinaison de secrets saisie, et comparaison à la clef publique de référence. -[Non-publié/Non-Stabilisé]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.3.1...master +[Non-publié/Non-Stabilisé]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.3.2...master +[Version 3.3.2]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.3.1...v3.3.2 [Version 3.3.1]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.3.0...v3.3.1 [Version 3.3.0]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.2.0...v3.3.0 [Version 3.2.0]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.1.0...v3.2.0 diff --git a/npm/package.json b/npm/package.json index a6ca082afb5049719c548dfe1c0bda1648d0abf0..13d812368194d3c6ac6e1a621d0bc27c7c190ba8 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "g1lib", - "version": "3.3.1", + "version": "3.3.2", "description": "An ubiquitous static javascript toolbox lib for Ǧ1 / Duniter ecosystem with reliability in mind.", "main": "nodejs/all.mjs", "browser": "browser/all.mjs", diff --git a/src/crypto.mjs b/src/crypto.mjs index 5fb9f298c2827c19e6aee93b9855ae58cd4d296e..4ae9c8f504809ccd0502803338f09a195fd012d9 100644 --- a/src/crypto.mjs +++ b/src/crypto.mjs @@ -1,15 +1,16 @@ // Alt deps : import {generate_keypair} from "ecma-nacl/build/lib/signing/sign.js"; // Alt deps : import scrypt from "ecma-nacl/build/lib/scrypt/scrypt.js"; import scrypt from '../generated/vendors/scrypt.mjs'; +import sha256 from '../node_modules/js-sha256/src/sha256.mjs'; import nacl from '../generated/vendors/nacl.mjs'; import * as ed25519 from '../node_modules/@noble/ed25519/lib/esm/index.js'; import sha from '../node_modules/js-sha256/src/sha256.mjs'; // Alt import * as ed25519 from '../node_modules/noble-ed25519/index.mjs'; import {b58, b64} from './basex.mjs'; -export {b58, b64}; +export {b58, b64, sha256}; -const sha256 = sha(); +const sha256Instance = sha256(); const generateKeypair = nacl.sign.keyPair.fromSeed; @@ -69,8 +70,8 @@ export function pubKey2shortKey(pubKey) { export function pubKey2checksum(b58pubKey, b58viewDependant = false, checksumWithLeadingZero = false, doubleSha256 = true) { const binPubKey = b58viewDependant ? b58.decode(b58pubKey) : pubKey2bin(b58pubKey); - let hash = sha256.digest(binPubKey); - if (doubleSha256) hash = sha256.digest(hash); + let hash = sha256Instance.digest(binPubKey); + if (doubleSha256) hash = sha256Instance.digest(hash); if (!checksumWithLeadingZero) { const shorterHash = sliceInitialsZero(hash); return b58.encode(shorterHash).substr(0, 3);