Overview
Comment: | Consolidated constants |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8ea3e826f346d919a1a69d641a831c64 |
User & Date: | rkeene on 2018-07-05 16:19:45 |
Other Links: | manifest | tags |
Context
2018-07-05
| ||
16:25 | Ensure that the test for address generation requests the right address format check-in: 8d7e39df83 user: rkeene tags: trunk | |
16:19 | Consolidated constants check-in: 8ea3e826f3 user: rkeene tags: trunk | |
15:09 | Automatically generate the version script from the exported symbols file check-in: 66d6dc7631 user: rkeene tags: trunk | |
Changes
Modified nano.c from [47a3dbb357] to [ec928b6713].
︙ | ︙ | |||
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include "randombytes.h" #include "tweetnacl.h" #include "blake2.h" #define NANO_SECRET_KEY_LENGTH (crypto_sign_SECRETKEYBYTES - crypto_sign_PUBLICKEYBYTES) #define NANO_PUBLIC_KEY_LENGTH (crypto_sign_PUBLICKEYBYTES) #define NANO_BLOCK_HASH_LENGTH 32 #define NANO_WORK_VALUE_LENGTH 8 #define NANO_WORK_HASH_LENGTH 8 #define NANO_WORK_DEFAULT_MIN 0xffffffc000000000LLU #define TclNano_AttemptAlloc(x) ((void *) Tcl_AttemptAlloc(x)) #define TclNano_Free(x) Tcl_Free((char *) x) static unsigned char *nano_parse_secret_key(Tcl_Obj *secret_key_only_obj, int *out_key_length) { unsigned char *secret_key, *public_key, *secret_key_only; int secret_key_length, secret_key_only_length; secret_key_only = Tcl_GetByteArrayFromObj(secret_key_only_obj, &secret_key_only_length); if (secret_key_only_length != NANO_SECRET_KEY_LENGTH) { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #include "randombytes.h" #include "tweetnacl.h" #include "blake2.h" #define NANO_SECRET_KEY_LENGTH (crypto_sign_SECRETKEYBYTES - crypto_sign_PUBLICKEYBYTES) #define NANO_PUBLIC_KEY_LENGTH (crypto_sign_PUBLICKEYBYTES) #define NANO_BLOCK_HASH_LENGTH 32 #define NANO_BLOCK_SIGNATURE_LENGTH crypto_sign_BYTES #define NANO_WORK_VALUE_LENGTH 8 #define NANO_WORK_HASH_LENGTH 8 #define NANO_WORK_DEFAULT_MIN 0xffffffc000000000LLU #define TclNano_AttemptAlloc(x) ((void *) Tcl_AttemptAlloc(x)) #define TclNano_Free(x) Tcl_Free((char *) x) #define TclNano_SetIntVar(interp, name, intValue) \ tclobj_ret = Tcl_SetVar2Ex(interp, name, NULL, Tcl_NewIntObj(intValue), TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG); \ if (!tclobj_ret) { \ return(TCL_ERROR); \ } #define TclNano_CreateNamespace(interp, name) \ tclobj_ret = Tcl_CreateNamespace(interp, name, NULL, NULL); \ if (!tclobj_ret) { \ return(TCL_ERROR); \ } #define TclNano_CreateObjCommand(interp, name, functionName) \ tclobj_ret = Tcl_CreateObjCommand(interp, name, functionName, NULL, NULL); \ if (!tclobj_ret) { \ return(TCL_ERROR); \ } #define TclNano_Eval(interp, script) \ tclcmd_ret = Tcl_Eval(interp, script); \ if (tclcmd_ret != TCL_OK) { \ return(tclcmd_ret); \ } #define TclNano_PkgProvide(interp, name, version) \ tclcmd_ret = Tcl_PkgProvide(interp, name, version); \ if (tclcmd_ret != TCL_OK) { \ return(tclcmd_ret); \ } static unsigned char *nano_parse_secret_key(Tcl_Obj *secret_key_only_obj, int *out_key_length) { unsigned char *secret_key, *public_key, *secret_key_only; int secret_key_length, secret_key_only_length; secret_key_only = Tcl_GetByteArrayFromObj(secret_key_only_obj, &secret_key_only_length); if (secret_key_only_length != NANO_SECRET_KEY_LENGTH) { |
︙ | ︙ | |||
173 174 175 176 177 178 179 | if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "data secretKey"); return(TCL_ERROR); } data = Tcl_GetByteArrayFromObj(objv[1], &data_length); | | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "data secretKey"); return(TCL_ERROR); } data = Tcl_GetByteArrayFromObj(objv[1], &data_length); signature_length = data_length + NANO_BLOCK_SIGNATURE_LENGTH; if (signature_length >= UINT_MAX) { Tcl_SetResult(interp, "Input message too long", NULL); return(TCL_ERROR); } secret_key = nano_parse_secret_key(objv[2], &secret_key_length); |
︙ | ︙ | |||
206 207 208 209 210 211 212 | TclNano_Free(signature); Tcl_SetResult(interp, "crypto_sign failed", NULL); return(TCL_ERROR); } | | | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | TclNano_Free(signature); Tcl_SetResult(interp, "crypto_sign failed", NULL); return(TCL_ERROR); } Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(signature, NANO_BLOCK_SIGNATURE_LENGTH)); TclNano_Free(signature); TclNano_Free(secret_key); return(TCL_OK); /* NOTREACH */ |
︙ | ︙ | |||
232 233 234 235 236 237 238 | Tcl_WrongNumArgs(interp, 1, objv, "data signature publicKey"); return(TCL_ERROR); } data = Tcl_GetByteArrayFromObj(objv[1], &data_length); signature = Tcl_GetByteArrayFromObj(objv[2], &signature_length); | | | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | Tcl_WrongNumArgs(interp, 1, objv, "data signature publicKey"); return(TCL_ERROR); } data = Tcl_GetByteArrayFromObj(objv[1], &data_length); signature = Tcl_GetByteArrayFromObj(objv[2], &signature_length); if (signature_length != NANO_BLOCK_SIGNATURE_LENGTH) { Tcl_SetResult(interp, "Signature is not the right size", NULL); return(TCL_ERROR); } public_key = Tcl_GetByteArrayFromObj(objv[3], &public_key_length); if (public_key_length != NANO_PUBLIC_KEY_LENGTH) { |
︙ | ︙ | |||
285 286 287 288 289 290 291 | return(TCL_OK); /* NOTREACH */ clientData = clientData; } static int nano_tcl_hash_data(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { | | | 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | return(TCL_OK); /* NOTREACH */ clientData = clientData; } static int nano_tcl_hash_data(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { unsigned char *data, result[NANO_BLOCK_SIGNATURE_LENGTH]; int tgifo_ret; int data_length, result_length; if (objc < 2 || objc > 3) { Tcl_WrongNumArgs(interp, 1, objv, "data ?hashLength?"); return(TCL_ERROR); |
︙ | ︙ | |||
314 315 316 317 318 319 320 | blake2b(result, result_length, data, data_length, NULL, 0); } else { /* * Default to the same as the cryptographic primitive */ crypto_hash(result, data, data_length); | | | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | blake2b(result, result_length, data, data_length, NULL, 0); } else { /* * Default to the same as the cryptographic primitive */ crypto_hash(result, data, data_length); result_length = NANO_BLOCK_SIGNATURE_LENGTH; } Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(result, result_length)); return(TCL_OK); /* NOTREACH */ |
︙ | ︙ | |||
501 502 503 504 505 506 507 | return(TCL_OK); /* NOTREACH */ clientData = clientData; } int Nano_Init(Tcl_Interp *interp) { | > | > > > > > > > > > > > > > > > > > | | | | | | | | | < | < < | < < | < < | < | 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | return(TCL_OK); /* NOTREACH */ clientData = clientData; } int Nano_Init(Tcl_Interp *interp) { void *tclobj_ret; int tclcmd_ret; const char nanoInitScript[] = { #include "nano.tcl.h" 0x00 }; #ifdef USE_TCL_STUBS const char *tclInitStubs_ret; /* Initialize Stubs */ tclInitStubs_ret = Tcl_InitStubs(interp, TCL_PATCH_LEVEL, 0); if (!tclInitStubs_ret) { return(TCL_ERROR); } #endif if (!interp) { return(TCL_OK); } TclNano_CreateNamespace(interp, "::nano"); TclNano_CreateNamespace(interp, "::nano::block"); TclNano_CreateNamespace(interp, "::nano::key"); TclNano_CreateNamespace(interp, "::nano::work"); TclNano_SetIntVar(interp, "::nano::block::hashLength", NANO_BLOCK_HASH_LENGTH); TclNano_SetIntVar(interp, "::nano::block::signatureLength", NANO_BLOCK_SIGNATURE_LENGTH); TclNano_SetIntVar(interp, "::nano::key::publicKeyLength", NANO_PUBLIC_KEY_LENGTH); TclNano_SetIntVar(interp, "::nano::key::privateKeyLength", NANO_SECRET_KEY_LENGTH); TclNano_SetIntVar(interp, "::nano::key::seedLength", NANO_SECRET_KEY_LENGTH); TclNano_SetIntVar(interp, "::nano::work::workValueLength", NANO_WORK_VALUE_LENGTH); TclNano_SetIntVar(interp, "::nano::work::workHashLength", NANO_WORK_HASH_LENGTH); TclNano_CreateObjCommand(interp, "::nano::internal::selfTest", nano_tcl_self_test); TclNano_CreateObjCommand(interp, "::nano::internal::generateKey", nano_tcl_generate_keypair); TclNano_CreateObjCommand(interp, "::nano::internal::generateSeed", nano_tcl_generate_seed); TclNano_CreateObjCommand(interp, "::nano::internal::publicKey", nano_tcl_secret_key_to_public_key); TclNano_CreateObjCommand(interp, "::nano::internal::signDetached", nano_tcl_sign_detached); TclNano_CreateObjCommand(interp, "::nano::internal::verifyDetached", nano_tcl_verify_detached); TclNano_CreateObjCommand(interp, "::nano::internal::hashData", nano_tcl_hash_data); TclNano_CreateObjCommand(interp, "::nano::internal::validateWork", nano_tcl_validate_work); TclNano_CreateObjCommand(interp, "::nano::internal::generateWork", nano_tcl_generate_work); TclNano_Eval(interp, nanoInitScript); TclNano_PkgProvide(interp, "nano", PACKAGE_VERSION); return(TCL_OK); } |
Modified nano.tcl from [0eebec2f4c] to [ef2578a7b0].
1 2 3 4 5 6 7 8 9 10 11 12 13 | #! /usr/bin/env tclsh package require json package require json::write namespace eval ::nano {} namespace eval ::nano::address {} namespace eval ::nano::key {} namespace eval ::nano::block {} namespace eval ::nano::block::create {} namespace eval ::nano::work {} namespace eval ::nano::account {} | < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #! /usr/bin/env tclsh package require json package require json::write namespace eval ::nano {} namespace eval ::nano::address {} namespace eval ::nano::key {} namespace eval ::nano::block {} namespace eval ::nano::block::create {} namespace eval ::nano::work {} namespace eval ::nano::account {} set ::nano::address::base32alphabet {13456789abcdefghijkmnopqrstuwxyz} proc ::nano::address::toPublicKey {address args} { set performChecksumCheck false set outputFormat "bytes" foreach arg $args { switch -exact -- $arg { "-verify" { |
︙ | ︙ |