diff --git a/CHANGELOG.fr.md b/CHANGELOG.fr.md index 3d38e64950392c844444cf5cc7f276733dfad674..006e1a3321ea13db2971da3c312a2f504264e2e6 100644 --- a/CHANGELOG.fr.md +++ b/CHANGELOG.fr.md @@ -10,9 +10,21 @@ et ce projet adhère au [versionnage sémantique](https://semver.org/spec/v2.0.0 - GraphQL stuff - @@@@ comme séparateur entre identifiant secret et mdp pour la génération de combinaison à tester (usage principal Gsper) - supprimer automatiquement le code inutile dans les lib (Tree Shaking) +- chiffrer déchiffrer des messages +- lire et écrire des messages au format cesium+ ## [Non-publié/Non-Stabilisé] (par [1000i100]) +## [Version 3.3.0] - 2022-09-30 (par [1000i100]) +### Ajouté +- crypto.isPubKey(pubKey) identique à checkKey mais retourne vrai ou faux là où checkKey throw une erreur en cas d'échec de validation. +- crypto.checkKey(pubKey) accepte désormais aussi les clefs sans checksum grace aux vérifications précises désormais effectuable sur la clef. +- crypto.checkKey(pubKey) accepte également les clefs au format binaire. +- crypto.isDuniterPubKey(b58pubKey) vérifie la conformité au Protocol Blockchain Duniter [V11](https://git.duniter.org/documents/rfcs/-/blob/master/rfc/0009_Duniter_Blockchain_Protocol_V11.md#public-key) et [V12](https://git.duniter.org/documents/rfcs/-/blob/master/rfc/0010_Duniter_Blockchain_Protocol_V12.md#public-key) +- crypto.isEd25519PubKey(b58pubKey) vérifie que la clef désigne bien un point sur la courbe ed25519 tel que défini dans la [RFC8032 5.1.3](https://www.rfc-editor.org/rfc/rfc8032#page-11) +### Corrections +- La CI ajuste désormais les chemins d'inclusion pour construire les builds static, que ces chemins sont décrits entre simple ou double guillemet. + ## [Version 3.2.0] - 2022-01-31 (par [1000i100]) ### Ajouté - crypto.checkKey(pubKeyWithChecksum) @@ -74,8 +86,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.2.0...master +[Non-publié/Non-Stabilisé]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.3.0...master +[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.1.0]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.0.3...v3.1.0 [Version 3.0.2]: https://git.duniter.org/libs/g1lib.js/-/compare/v3.0.1...v3.0.2 diff --git a/npm/package.json b/npm/package.json index c729a9786fe84f71d6ec32c3c37fd12fed00a207..152c27660c00c563666163bb7c19dd7ce916518a 100644 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "g1lib", - "version": "3.2.0", + "version": "3.3.0", "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/package.json b/package.json index e7fd8da31a1096755135e54d15366bb6bbe6e7dd..a4b134954bd4f694433a9e0fc5476a9b999e5862 100644 --- a/package.json +++ b/package.json @@ -33,11 +33,11 @@ "watch2null": "chokidar src/* -c \"npm run test:dev:runTests 2>/dev/null\"" }, "dependencies": { + "@noble/ed25519": "^1.7.1", "cross-fetch": "^3.1.5", "ed2curve": "https://github.com/1000i100/ed2curve#master", "js-sha256": "github:1000i100/js-sha256#master", "latinize-to-ascii": "^0.5.2", - "@noble/ed25519": "^1.7.1", "node-fetch": "^3.2.10", "scrypt-async-modern": "^3.0.12", "tweetnacl": "^1.0.3" diff --git a/src/crypto.mjs b/src/crypto.mjs index d0479396b657af888e925b075b8e84687c1f09d4..4ad66372bd95a74dd5ea13ab7a1a19b40e9a4a9f 100644 --- a/src/crypto.mjs +++ b/src/crypto.mjs @@ -133,17 +133,17 @@ export function isEd25519PubKey(b58pubKey){ return true; } -export function checkKey(pubKeyWithOrWithoutChecksum, checkRawPubKey= true) { - const binPubKey = pubKey2bin(pubKeyWithOrWithoutChecksum) +export function checkKey(pubKey, checkRawPubKey= true) { + const binPubKey = pubKey2bin(pubKey) const b58pubKey = b58.encode(binPubKey); if(!checkRawPubKey) return true; if(!isDuniterPubKey(b58pubKey)) throw new Error("Invalid public key : this string don't follow rfc/0009_Duniter_Blockchain_Protocol_V11.md#public-key"); if(!isEd25519PubKey(b58pubKey)) throw new Error("Invalid public key : not a valid ed25519 point RFC8032 5.1.3 https://www.rfc-editor.org/rfc/rfc8032#page-11"); return true; } -export function isPubKey(b58pubKey){ +export function isPubKey(pubKey){ try{ - return checkKey(b58pubKey) + return checkKey(pubKey) } catch (e){return false;} }