Skip to content
Snippets Groups Projects
Commit 6be3ecc3 authored by Millicent Billette's avatar Millicent Billette
Browse files

v3.3.2, export sha256

parent 177bfa5e
No related branches found
No related tags found
No related merge requests found
Pipeline #17657 passed with warnings
...@@ -15,6 +15,10 @@ et ce projet adhère au [versionnage sémantique](https://semver.org/spec/v2.0.0 ...@@ -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]) ## [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]) ## [Version 3.3.1] - 2022-09-30 (par [1000i100])
### Corrections ### 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 - 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 ...@@ -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 - 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. - 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.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.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 [Version 3.2.0]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.1.0...v3.2.0
......
{ {
"name": "g1lib", "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.", "description": "An ubiquitous static javascript toolbox lib for Ǧ1 / Duniter ecosystem with reliability in mind.",
"main": "nodejs/all.mjs", "main": "nodejs/all.mjs",
"browser": "browser/all.mjs", "browser": "browser/all.mjs",
......
// Alt deps : import {generate_keypair} from "ecma-nacl/build/lib/signing/sign.js"; // 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"; // Alt deps : import scrypt from "ecma-nacl/build/lib/scrypt/scrypt.js";
import scrypt from '../generated/vendors/scrypt.mjs'; 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 nacl from '../generated/vendors/nacl.mjs';
import * as ed25519 from '../node_modules/@noble/ed25519/lib/esm/index.js'; import * as ed25519 from '../node_modules/@noble/ed25519/lib/esm/index.js';
import sha from '../node_modules/js-sha256/src/sha256.mjs'; import sha from '../node_modules/js-sha256/src/sha256.mjs';
// Alt import * as ed25519 from '../node_modules/noble-ed25519/index.mjs'; // Alt import * as ed25519 from '../node_modules/noble-ed25519/index.mjs';
import {b58, b64} from './basex.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; const generateKeypair = nacl.sign.keyPair.fromSeed;
...@@ -69,8 +70,8 @@ export function pubKey2shortKey(pubKey) { ...@@ -69,8 +70,8 @@ export function pubKey2shortKey(pubKey) {
export function pubKey2checksum(b58pubKey, b58viewDependant = false, checksumWithLeadingZero = false, doubleSha256 = true) { export function pubKey2checksum(b58pubKey, b58viewDependant = false, checksumWithLeadingZero = false, doubleSha256 = true) {
const binPubKey = b58viewDependant ? b58.decode(b58pubKey) : pubKey2bin(b58pubKey); const binPubKey = b58viewDependant ? b58.decode(b58pubKey) : pubKey2bin(b58pubKey);
let hash = sha256.digest(binPubKey); let hash = sha256Instance.digest(binPubKey);
if (doubleSha256) hash = sha256.digest(hash); if (doubleSha256) hash = sha256Instance.digest(hash);
if (!checksumWithLeadingZero) { if (!checksumWithLeadingZero) {
const shorterHash = sliceInitialsZero(hash); const shorterHash = sliceInitialsZero(hash);
return b58.encode(shorterHash).substr(0, 3); return b58.encode(shorterHash).substr(0, 3);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment