DS is a javascript to call A2B CodeMap API methods of KeyGenerator(), DsSigner() and DsVerifier()
- v0.1.0, 2016-05-21
- v0.2.0, 2025-10-14
- SHA1: 20b9cf082f0214b0620c7c2399281eeb4db198da *DS.js
- node (~=v0.10.32)
- crypto
- benchmark
- fs
- randomstring
- tweetnacl
- tweetnacl/nacl-fast
- js-nacl
Attributes:
EdDSA: Edwards-curve Digital Signature Algorithm
KeyPair generation using asymmetric random seed
id: user id, char[16]
public_key: public key
**Save keyparis in local folder (Temporary disposal options)
Digital signature generation using asymmetric encryption private key
-
_MessageBytes: information messages in bytes -
method: digital signautre method- EdDSA: EdDSA
-
para: -
"curves": curves25519, default
- "private_key": private key file path
_SignatureBytes: signature data bytes
Digital signature verifiy using asymmetric encryption public key
-
_MessageBytes: information messages in bytes -
_SignatureBytes: signature data bytes from '_MessageBytes' -
method: digital signautre verified method- EdDSA: EdDSA, default
-
para:- "curves": curves25519, default
- "public_key": public key file path
_VerifyCheckBoolean: boolean value of signature validation result
var fs = require('fs');
var ds = require("./DS");
function toUint8Array(buffer) {
var out = new Uint8Array(buffer.length);
for (var i = 0; i < buffer.length; ++i) {
out[i] = buffer[i];
}
return out;
}
//生成密钥对过程
var test1 =function(id){
var public_key = ds.KeyGenerator(id); //生成密钥API
}
//签名过程
var test2 = function(id, _message){
var private_key = toUint8Array(fs.readFileSync(id+"_private.pem"));
var ds_para = {
"curves": "curves25519",
"private_key": private_key
};
var method = "Ed25519";
_sig = ds.DsSigner(_message, method, ds_para); //签名API
return _sig
}
//验证过程
var test3 = function(id, _message,_sig){
public_key = toUint8Array(fs.readFileSync(id+"_public.pem"));
ds_para = {
"curves": "curves25519",
"public_key": public_key
};
var method = "Ed25519";
v = ds.DsVerifier(_message, _sig, method, ds_para); //验证签名API
return v;
}
var id = "1234567";
var _message = ds.string_to_Uint8Array("This is my message. You can tell people about this one.");
_sig=test2(id,_message);
console.log(new Buffer(_sig).toString('base64'));
console.log(_sig.length);
v=test3(id,_message,_sig);
console.log(v);
Run npm install followed by npm start to launch the REST signing service (default port 3000).
HTTP POST /sign
{
"id": "1234567",
"content": "string payload to sign",
"token": "change-me"
}
Responses:
200 OK–{ "signature": "base64 signature" }400/403/404–{ "error": "..." }when validation fails429– rejected when the same IP calls more frequently than once per 300ms (IPs are appended torate-limit.log)
HTTP POST /verify
{
"id": "1234567",
"content": "string payload to sign",
"token": "change-me",
"signature": "base64 signature"
}
Responses:
200 OK–{ "valid": true|false }400/403/404–{ "error": "..." }when validation fails or the signature cannot be decoded429– identical rate-limit behavior as/sign
- Signature
curl -X POST http://localhost:3000/sign \
-H "Content-Type: application/json" \
-d '{"id":"1234567","content":"hello world","token":"change-me"}'
{"signature":"v85RXXiFgwpLrmPomswaRRh1IOlvKIipfaAxEU67ZOJBfCb6b4Tx1aL2ZG7pTPLzSpBpB0XnrU7GBnENGsvFAQ=="}- Verify
curl -X POST http://192.168.3.3:3000/verify \
-H "Content-Type: application/json" \
-d '{"id":"1234567","content":"hello world","token":"change-me","signature":"v85RXXiFgwpLrmPomswaRRh1IOlvKIipfaAxEU67ZOJBfCb6b4Tx1aL2ZG7pTPLzSpBpB0XnrU7GBnENGsvFAQ=="}'
{"valid":true}If you happen to find any bugs, join our slack and tell us about it there.
If you have any problems running the DS, here are a few things to try:
- Make sure you setup the right version of node using npm or nvm。
- If none of that helps, feel free to email me or submit an issue. I might have left out an important detail here or there :).
- BENM
The MIT License (MIT)
Copyright © 2025 ZimablueAI
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.