Overview
| Comment: | More options for signing and verifying a block |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
53b03b2ef60a7c7d6165159c595ffd4e |
| User & Date: | rkeene on 2018-07-02 23:24:36.511 |
| Other Links: | manifest | tags |
Context
|
2018-07-02
| ||
| 23:33 | Start of work on a Tcl-based random processor -- but for now disable all randomness check-in: 180aff4740 user: rkeene tags: trunk | |
| 23:24 | More options for signing and verifying a block check-in: 53b03b2ef6 user: rkeene tags: trunk | |
| 23:13 | Consolidated some constants check-in: 8670bc6274 user: rkeene tags: trunk | |
Changes
Modified build/test/test.tcl
from [4f0bb6d25d]
to [b87fa00f0f].
| ︙ | |||
200 201 202 203 204 205 206 207 208 209 210 211 212 213 | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | + + + + + + + + + |
if {$blockSignature ne $blockSignature_expected} {
puts "\[3.FAIL\] Got: $blockSignature"
puts "\[3.FAIL\] Exp: $blockSignature_expected"
return false
}
# Verifying a block
set signature [::nano::block::signBlockJSON $block $key -hex]
set verify [::nano::block::verifyBlockJSON $block $signature [::nano::key::publicKeyFromPrivateKey $key]]
if {!$verify} {
puts "\[4.FAIL\] Got: $verify"
puts "\[4.FAIL\] Exp: true"
return false
}
return true
}
set tests {
selftest
signatures
|
| ︙ |
Modified nano.tcl
from [99086640a8]
to [e1a8e5a90c].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | + |
#! /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::account {}
set ::nano::block::hashLength 32
set ::nano::block::signatureLength 64
set ::nano::key::publicKeyLength 32
set ::nano::key::privateKeyLength 32
set ::nano::key::seedLength 32
set ::nano::address::base32alphabet {13456789abcdefghijkmnopqrstuwxyz}
proc ::nano::address::toPublicKey {address args} {
set performChecksumCheck false
|
| ︙ | |||
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | + + + + + + + + + + - + + + + + + + |
}
proc ::nano::block::signBlock {blockData args} {
set blockHash [::nano::block::hash $blockData]
tailcall ::nano::block::signBlockHash $blockHash {*}$args
}
proc ::nano::block::signBlockJSON {blockJSON args} {
set blockData [::nano::block::fromJSON $blockJSON]
tailcall ::nano::block::signBlock $blockData {*}$args
}
proc ::nano::block::verifyBlockHash {blockHash signature pubKey} {
if {[string length $blockHash] != $::nano::block::hashLength} {
set blockHash [binary decode hex $blockHash]
}
if {[string length $signature] != $::nano::block::signatureLength} {
set signature [binary decode hex $signature]
}
if {[string length $pubKey] != $::nano::key::publicKeyLength} {
set key [binary decode hex $pubKey]
}
set valid [::nano::internal::verifyDetached $blockHash $signature $pubKey]
|
| ︙ |