Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
|||
var [const] MsgHash=Import("zklMsgHash"); // SHA-256, etc
|
||||
const symbols="123456789" // 58 characters: no cap i,o; ell, zero
|
||||
"ABCDEFGHJKLMNPQRSTUVWXYZ"
|
||||
"abcdefghijkmnopqrstuvwxyz";
|
||||
|
||||
fcn unbase58(str){ // --> Data (byte bucket)
|
||||
out:=Data().fill(0,25);
|
||||
str.pump(Void,symbols.index,'wrap(n){ // throws on out of range
|
||||
[24..0,-1].reduce('wrap(c,idx){
|
||||
c+=58*out[idx]; // throws if not enough data
|
||||
out[idx]=c;
|
||||
c/256; // should be zero when done
|
||||
},n) : if(_) throw(Exception.ValueError("address too long"));
|
||||
});
|
||||
out;
|
||||
}
|
||||
|
||||
fcn coinValide(addr){
|
||||
reg dec,chkSum;
|
||||
try{ dec=unbase58(addr) }catch{ return(False) }
|
||||
chkSum=dec[-4,*]; dec.del(21,*);
|
||||
// hash then hash the hash --> binary hash (instead of hex string)
|
||||
(2).reduce(MsgHash.SHA256.fp1(1,dec),dec); // dec is i/o buffer
|
||||
dec[0,4]==chkSum;
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
T("1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i","1Q1pE5vPGEEMqRcVRMbtBK842Y6Pzo6nK9",
|
||||
"1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62X", // checksum changed, original data.
|
||||
"1ANNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i", // data changed, original checksum.
|
||||
"1A Na15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i", // invalid chars
|
||||
"1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62izz", // too long
|
||||
).apply(coinValide).println();
|
||||
Loading…
Add table
Add a link
Reference in a new issue