让各个编码转换的方法 (b58_to_hex, hex_to_b32, ...) 在错误情况下返回 '' 而不是 null。不知道会不会导致其它地方的问题。

This commit is contained in:
luk 2024-11-03 11:50:21 +08:00
parent decdcab1e5
commit 62acb1c453
5 changed files with 88 additions and 530 deletions

View File

@ -1,234 +0,0 @@
<mxfile host="65bd71144e">
<diagram id="tEJiczfqJVlhZvufAVre" name="Page-1">
<mxGraphModel dx="845" dy="542" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="2" value="Data" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#008a00;strokeColor=#005700;fontColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="40" y="90" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="6" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="4" target="5" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="4" value="Entropy&lt;br&gt;16 Bytes" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#008a00;strokeColor=#005700;fontColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="10" y="250" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="9" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="5" target="8" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="5" value="bip39" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="160" y="250" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="7" value="Algorithm" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="230" y="90" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="11" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="8" target="10" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="12" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="8" target="5" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="8" value="Mnemonic ^ 密语 ^ Secword&lt;br&gt;12 words" style="whiteSpace=wrap;html=1;rounded=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="310" y="250" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="13" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="10" target="8" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="15" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="10" target="14" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="10" value="hdkey" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="470" y="250" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="17" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="14" target="16" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="48" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="14" target="47" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="59" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="14" target="58" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="19" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="16" target="18" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="16" value="椭圆曲线算法&lt;br&gt;secp256k1" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="770" y="250" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="96" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="18" target="53" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="98" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" source="18" target="57" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="18" value="public key ^ 公钥&lt;br&gt;264 bits = 33 Bytes = 66 Hex" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="910" y="250" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="28" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="20" target="27" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="20" value="&lt;ol&gt;&lt;li&gt;sha256&lt;/li&gt;&lt;li&gt;ripemd160&lt;/li&gt;&lt;/ol&gt;" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;align=left;" parent="1" vertex="1">
<mxGeometry x="1055" y="130" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="30" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="24" target="29" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="24" value="&lt;ol&gt;&lt;li&gt;decompress&lt;/li&gt;&lt;li&gt;keccak256&lt;/li&gt;&lt;li&gt;slice(40)&lt;/li&gt;&lt;/ol&gt;" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;align=left;" parent="1" vertex="1">
<mxGeometry x="1055" y="250" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="32" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="25" target="31" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="25" value="&lt;ol&gt;&lt;li&gt;sha256&lt;/li&gt;&lt;li&gt;ripemd160&lt;/li&gt;&lt;/ol&gt;" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;align=left;" parent="1" vertex="1">
<mxGeometry x="1050" y="360" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="34" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="27" target="33" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="27" value="position of BTC&lt;br&gt;20 Bytes = 40 Hex" style="whiteSpace=wrap;html=1;rounded=1;fontColor=#ffffff;align=center;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="1190" y="130" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="36" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="29" target="35" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="29" value="position of ETH&lt;br&gt;20 Bytes = 40 Hex" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;align=center;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="1190" y="250" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="38" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="31" target="37" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="31" value="Position of TIC&lt;br&gt;20 Bytes = 40 Hex" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;align=center;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="1190" y="360" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="42" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="33" target="41" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="33" value="&lt;ol&gt;&lt;li&gt;protocol prefix +1B&lt;/li&gt;&lt;li&gt;cksum postfix +4B&lt;/li&gt;&lt;li&gt;base58btc&lt;/li&gt;&lt;/ol&gt;" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;align=left;" parent="1" vertex="1">
<mxGeometry x="1340" y="130" width="150" height="60" as="geometry"/>
</mxCell>
<mxCell id="39" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="35" target="29" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="91" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="35" target="43" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="35" value="&lt;ol&gt;&lt;li&gt;&lt;span&gt;大小写(EIP55)&lt;/span&gt;&lt;br&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;'0x' prefix&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;align=left;" parent="1" vertex="1">
<mxGeometry x="1340" y="250" width="150" height="60" as="geometry"/>
</mxCell>
<mxCell id="40" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="37" target="31" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="46" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="37" target="45" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="37" value="&lt;ol&gt;&lt;li&gt;world prefix +1B&lt;/li&gt;&lt;li&gt;cksum postfix +3B&lt;/li&gt;&lt;li&gt;base64url&lt;/li&gt;&lt;/ol&gt;" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;align=left;" parent="1" vertex="1">
<mxGeometry x="1340" y="360" width="150" height="60" as="geometry"/>
</mxCell>
<mxCell id="41" value="address of BTC&lt;br&gt;26~34 b58" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;align=center;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="1520" y="130" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="92" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="43" target="35" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="43" value="address of ETH&lt;br&gt;'0x' + 40 Hex" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;align=center;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="1520" y="250" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="45" value="address of TIC&lt;br&gt;32 b64u" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;align=center;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="1520" y="360" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="50" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="47" target="49" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="47" value="sign ^ 签署" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="620" y="430" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="56" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;startArrow=none;startFill=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="51" target="53" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points"/>
</mxGeometry>
</mxCell>
<mxCell id="97" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" source="49" target="53" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="49" value="Signature ^ 签印&lt;br&gt;7172 Bytes = 142/144 Hex" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="620" y="560" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="53" value="verify ^ 验签" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="910" y="430" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="103" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" parent="1" source="57" target="64" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="1000" y="40"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="57" value="encrypt ^ 加密" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="910" y="120" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="105" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" target="61" edge="1">
<mxGeometry relative="1" as="geometry">
<mxPoint x="710" y="150" as="sourcePoint"/>
</mxGeometry>
</mxCell>
<mxCell id="58" value="decrypt ^ 解密" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="620" y="120" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="104" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="64" target="58" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="64" value="ciphertext ^ 密文" style="whiteSpace=wrap;html=1;rounded=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="770" y="10" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="87" value="" style="endArrow=classic;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="18" target="25" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="8" y="610" as="sourcePoint"/>
<mxPoint x="208" y="650" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="88" value="" style="endArrow=classic;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="18" target="20" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="80" y="830" as="sourcePoint"/>
<mxPoint x="130" y="780" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="89" value="" style="endArrow=classic;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;" parent="1" source="18" target="24" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="2" y="610" as="sourcePoint"/>
<mxPoint x="328" y="740" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="14" value="private key ^ 私钥&lt;br&gt;256 bits = 32 Bytes = 64 Hex" style="whiteSpace=wrap;html=1;rounded=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="620" y="250" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="95" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="51" target="47" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="51" value="作品=&amp;gt;哈希" style="whiteSpace=wrap;html=1;rounded=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="770" y="430" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="106" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="61" target="57" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="61" value="plaintext ^ 明文" style="whiteSpace=wrap;html=1;rounded=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="770" y="120" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="111" value="prikey_to_pubkey" style="shape=partialRectangle;whiteSpace=wrap;html=1;bottom=1;right=1;left=1;top=0;fillColor=#1ba1e2;routingCenterX=-0.5;strokeColor=#006EAF;fontColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="680" y="650" width="290" height="30" as="geometry"/>
</mxCell>
<mxCell id="112" value="secword_to_keypair" style="shape=partialRectangle;whiteSpace=wrap;html=1;bottom=1;right=1;left=1;top=0;fillColor=#1ba1e2;routingCenterX=-0.5;strokeColor=#006EAF;fontColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="420" y="710" width="610" height="30" as="geometry"/>
</mxCell>
<mxCell id="113" value="pubkey_to_address" style="shape=partialRectangle;whiteSpace=wrap;html=1;bottom=1;right=1;left=1;top=0;fillColor=#1ba1e2;routingCenterX=-0.5;strokeColor=#006EAF;fontColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="970" y="650" width="630" height="30" as="geometry"/>
</mxCell>
<mxCell id="114" value="prikey_to_address" style="shape=partialRectangle;whiteSpace=wrap;html=1;bottom=1;right=1;left=1;top=0;fillColor=#1ba1e2;routingCenterX=-0.5;strokeColor=#006EAF;fontColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="680" y="730" width="920" height="30" as="geometry"/>
</mxCell>
<mxCell id="115" value="secword_to_address, secword_to_account" style="shape=partialRectangle;whiteSpace=wrap;html=1;bottom=1;right=1;left=1;top=0;fillColor=#1ba1e2;routingCenterX=-0.5;strokeColor=#006EAF;fontColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="360" y="770" width="1240" height="30" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

View File

@ -1,230 +0,0 @@
<mxfile host="65bd71144e">
<diagram id="tEJiczfqJVlhZvufAVre" name="Page-1">
<mxGraphModel dx="845" dy="542" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="2" value="Data" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#008a00;strokeColor=#005700;fontColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="40" y="40" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="6" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="4" target="5" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="4" value="Entropy&lt;br&gt;16 Bytes" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#008a00;strokeColor=#005700;fontColor=#ffffff;" parent="1" vertex="1">
<mxGeometry x="308" y="20" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="9" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="5" target="8" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="5" value="bip39" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="308" y="120" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="7" value="Algorithm" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="40" y="130" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="11" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" parent="1" source="8" target="10" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="12" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="8" target="5" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="8" value="Mnemonic ^ 密语 ^ Secword&lt;br&gt;12 words" style="whiteSpace=wrap;html=1;rounded=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="308" y="220" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="13" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="10" target="8" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="15" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="10" target="14" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="10" value="hdkey" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="308" y="324.5" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="17" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="14" target="16" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="48" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="14" target="47" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="59" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="14" target="58" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="14" value="private key ^ 私钥&lt;br&gt;256 bits = 32 Bytes = 64 Hex" style="whiteSpace=wrap;html=1;rounded=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="308" y="420" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="19" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="16" target="18" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="16" value="椭圆曲线算法&lt;br&gt;secp256k1" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="308" y="520" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="54" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="18" target="53" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="84" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;startArrow=none;startFill=0;" parent="1" source="18" target="57" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="18" value="public key ^ 公钥&lt;br&gt;264 bits = 33 Bytes = 66 Hex" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="308" y="640" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="28" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="20" target="27" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="20" value="&lt;ol&gt;&lt;li&gt;sha256&lt;/li&gt;&lt;li&gt;ripemd160&lt;/li&gt;&lt;/ol&gt;" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;align=left;" parent="1" vertex="1">
<mxGeometry x="170" y="780" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="30" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="24" target="29" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="24" value="&lt;ol&gt;&lt;li&gt;decompress&lt;/li&gt;&lt;li&gt;keccak256&lt;/li&gt;&lt;li&gt;slice(40)&lt;/li&gt;&lt;/ol&gt;" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;align=left;" parent="1" vertex="1">
<mxGeometry x="312" y="780" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="32" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="25" target="31" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="25" value="&lt;ol&gt;&lt;li&gt;sha256&lt;/li&gt;&lt;li&gt;ripemd160&lt;/li&gt;&lt;/ol&gt;" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;align=left;" parent="1" vertex="1">
<mxGeometry x="469" y="780" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="34" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="27" target="33" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="27" value="position of BTC&lt;br&gt;20 Bytes = 40 Hex" style="whiteSpace=wrap;html=1;rounded=1;fontColor=#ffffff;align=center;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="170" y="880" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="36" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="29" target="35" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="29" value="position of ETH&lt;br&gt;20 Bytes = 40 Hex" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;align=center;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="318" y="879" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="38" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="31" target="37" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="31" value="Position of TIC&lt;br&gt;20 Bytes = 40 Hex" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;align=center;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="478" y="880" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="42" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="33" target="41" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="33" value="&lt;ol&gt;&lt;li&gt;protocol prefix +1B&lt;/li&gt;&lt;li&gt;cksum postfix +4B&lt;/li&gt;&lt;li&gt;base58btc&lt;/li&gt;&lt;/ol&gt;" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;align=left;" parent="1" vertex="1">
<mxGeometry x="160" y="980" width="150" height="60" as="geometry"/>
</mxCell>
<mxCell id="39" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="35" target="29" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="44" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="35" target="43" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="378" y="1060"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="35" value="&lt;ol&gt;&lt;li&gt;&lt;span&gt;大小写(EIP55)&lt;/span&gt;&lt;br&gt;&lt;/li&gt;&lt;li&gt;&lt;span&gt;'0x' prefix&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;align=left;" parent="1" vertex="1">
<mxGeometry x="312" y="980" width="150" height="60" as="geometry"/>
</mxCell>
<mxCell id="40" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="37" target="31" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="46" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=classic;startFill=1;" parent="1" source="37" target="45" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="37" value="&lt;ol&gt;&lt;li&gt;world prefix +1B&lt;/li&gt;&lt;li&gt;cksum postfix +3B&lt;/li&gt;&lt;li&gt;base64url&lt;/li&gt;&lt;/ol&gt;" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;align=left;" parent="1" vertex="1">
<mxGeometry x="469" y="980" width="150" height="60" as="geometry"/>
</mxCell>
<mxCell id="41" value="address of BTC&lt;br&gt;26~34 b58" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;align=center;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="170" y="1080" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="43" value="address of ETH&lt;br&gt;'0x' + 40 Hex" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;align=center;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="318" y="1080" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="45" value="address of TIC&lt;br&gt;32 b64u" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;align=center;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="479" y="1080" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="50" value="" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="47" target="49" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="47" value="sign ^ 签署" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="140" y="420" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="56" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;startArrow=none;startFill=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="49" target="53" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points"/>
</mxGeometry>
</mxCell>
<mxCell id="49" value="Signature ^ 签印&lt;br&gt;7172 Bytes = 142/144 Hex" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="140" y="520" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="52" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;startArrow=none;startFill=0;" parent="1" source="51" target="47" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="70" y="520"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="55" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="51" target="53" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="70" y="620"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="51" value="作品=&amp;gt;哈希" style="whiteSpace=wrap;html=1;rounded=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="10" y="520" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="53" value="verify ^ 验签" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="140" y="640" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="82" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=1;entryDx=0;entryDy=0;startArrow=none;startFill=0;" parent="1" source="57" target="64" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="659" y="630"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="57" value="encrypt ^ 加密" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="469" y="640" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="80" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;startArrow=none;startFill=0;" parent="1" source="58" target="61" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="58" value="decrypt ^ 解密" style="shape=parallelogram;perimeter=parallelogramPerimeter;whiteSpace=wrap;html=1;fixedSize=1;rounded=1;fontColor=#ffffff;strokeColor=#A50040;fillColor=#d80073;" parent="1" vertex="1">
<mxGeometry x="469" y="420" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="81" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;startArrow=none;startFill=0;" parent="1" source="61" target="57" edge="1">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="61" value="plaintext ^ 明文" style="whiteSpace=wrap;html=1;rounded=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="469" y="520" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="83" style="edgeStyle=elbowEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;startArrow=none;startFill=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;" parent="1" source="64" target="58" edge="1">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="659" y="490"/>
</Array>
</mxGeometry>
</mxCell>
<mxCell id="64" value="ciphertext ^ 密文" style="whiteSpace=wrap;html=1;rounded=1;fontColor=#ffffff;strokeColor=#005700;fillColor=#008a00;" parent="1" vertex="1">
<mxGeometry x="599" y="520" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="87" value="" style="endArrow=classic;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="18" target="25" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="378" y="750" as="sourcePoint"/>
<mxPoint x="578" y="790" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="88" value="" style="endArrow=classic;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="18" target="20" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="450" y="970" as="sourcePoint"/>
<mxPoint x="500" y="920" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="89" value="" style="endArrow=classic;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="1" source="18" target="24" edge="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="372" y="750" as="sourcePoint"/>
<mxPoint x="698" y="880" as="targetPoint"/>
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 KiB

32
test.js
View File

@ -16,11 +16,7 @@ function ECPointDecompress (comp) {
var x = new bigInt(comp.substring(2), 16) var x = new bigInt(comp.substring(2), 16)
// y mod p = +-(x^3 + 7)^((p+1)/4) mod p // y mod p = +-(x^3 + 7)^((p+1)/4) mod p
console.log('ECP x=', x.toString(), ' = ', x.toString(16)) console.log('ECP x=', x.toString(), ' = ', x.toString(16))
var y = x var y = x.modPow(3, prime).add(7).mod(prime).modPow(pIdent, prime)
.modPow(3, prime)
.add(7)
.mod(prime)
.modPow(pIdent, prime)
// If the parity doesn't match it's the *other* root // If the parity doesn't match it's the *other* root
console.log('ECP y=', y.toString(), ' = ', y.toString(16)) console.log('ECP y=', y.toString(), ' = ', y.toString(16))
if (y.mod(2).toJSNumber() !== signY) { if (y.mod(2).toJSNumber() !== signY) {
@ -40,32 +36,17 @@ BigNumber = require('bignumber.js')
function uncompressPubkey (comp) { function uncompressPubkey (comp) {
// Consts for P256 curve. Adjust accordingly // Consts for P256 curve. Adjust accordingly
const prime = new BigNumber('fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f', 16).integerValue(), const prime = new BigNumber('fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f', 16).integerValue(),
pIdent = prime pIdent = prime.plus(1).idiv(4).integerValue()
.plus(1)
.idiv(4)
.integerValue()
console.log('pIdent=', pIdent.toString(), ' = ', pIdent.toString(16)) console.log('pIdent=', pIdent.toString(), ' = ', pIdent.toString(16))
var signY = new Number(comp[1]) - 2 var signY = new Number(comp[1]) - 2
var x = new BigNumber(comp.substring(2), 16).integerValue() var x = new BigNumber(comp.substring(2), 16).integerValue()
console.log('x=', x.toString(), ' = ', x.toString(16)) console.log('x=', x.toString(), ' = ', x.toString(16))
// y^2 = x^3 - 3x + b // y^2 = x^3 - 3x + b
var y = x var y = x.pow(3).mod(prime).plus(7).mod(prime).pow(pIdent).mod(prime).integerValue()
.pow(3)
.mod(prime)
.plus(7)
.mod(prime)
.pow(pIdent)
.mod(prime)
.integerValue()
console.log('y=', y.toString(), ' = ', y.toString(16)) console.log('y=', y.toString(), ' = ', y.toString(16))
// If the parity doesn't match it's the *other* root // If the parity doesn't match it's the *other* root
if ( if (y.mod(2).integerValue().toNumber() !== signY) {
y
.mod(2)
.integerValue()
.toNumber() !== signY
) {
// y = prime - y // y = prime - y
y = prime.minus(y).integerValue() y = prime.minus(y).integerValue()
} }
@ -129,10 +110,7 @@ crypto.createCipheriv('aes-256-cfb', Buffer.from(acc.prikey, 'hex'), Buffer.allo
////////////////////// crypto + PEM ////////////////////// crypto + PEM
toPEM = function (kp) { toPEM = function (kp) {
let pubkey = crypto let pubkey = crypto.createECDH('secp256k1').setPrivateKey(kp.prikey, 'hex').getPublicKey('hex', 'compressed')
.createECDH('secp256k1')
.setPrivateKey(kp.prikey, 'hex')
.getPublicKey('hex', 'compressed')
console.log('ECDH created publickey = ', pubkey) console.log('ECDH created publickey = ', pubkey)
let mykey = '308187020100301306072a8648ce3d020106082a8648ce3d030107046d306b0201010420' + kp.prikey + 'a144034200' + pubkey let mykey = '308187020100301306072a8648ce3d020106082a8648ce3d030107046d306b0201010420' + kp.prikey + 'a144034200' + pubkey
console.log(mykey) console.log(mykey)

122
ticc.js
View File

@ -976,6 +976,17 @@ class TicCrypto {
return text return text
} }
static randomize_hex ({ length = 64 } = {}) {
// 长度为 length 的随机 hex 字符串。注意 randomBytes 在一些环境里可能不存在,例如在 HBuilderX 的内置浏览器里。
if (crypto.randomBytes) {
return crypto
.randomBytes(Math.ceil(length / 2))
.toString('hex')
.slice(0, length)
}
return this.randomize_string({ length, alphabet: '0123456789abcdef' })
}
/** /**
* 生成随机的数字 * 生成随机的数字
* *
@ -1275,7 +1286,7 @@ class TicCrypto {
try { try {
return bs58check.encode(Buffer.from(hex, 'hex')) return bs58check.encode(Buffer.from(hex, 'hex'))
} catch (exception) { } catch (exception) {
return null return ''
} }
} }
@ -1283,7 +1294,7 @@ class TicCrypto {
try { try {
return bs58.encode(Buffer.from(hex, 'hex')) return bs58.encode(Buffer.from(hex, 'hex'))
} catch (exception) { } catch (exception) {
return null return ''
} }
} }
@ -1299,7 +1310,7 @@ class TicCrypto {
try { try {
return bs58check.decode(box).toString('hex') return bs58check.decode(box).toString('hex')
} catch (exception) { } catch (exception) {
return null return ''
} }
} }
@ -1307,7 +1318,7 @@ class TicCrypto {
try { try {
return bs58.decode(box).toString('hex') return bs58.decode(box).toString('hex')
} catch (exception) { } catch (exception) {
return null return ''
} }
} }
@ -1336,10 +1347,10 @@ class TicCrypto {
* @memberof TicCrypto * @memberof TicCrypto
*/ */
static hex_to_b64t (hex) { static hex_to_b64t (hex) {
if (/^[0-9a-fA-F]+$/.test(hex)) { if (my.REGEXP_ALPHABET.hex.test(hex)) {
return this.b64_to_b64t(Buffer.from(hex, 'hex').toString('base64')) return this.b64_to_b64t(Buffer.from(hex, 'hex').toString('base64'))
} }
return null return ''
} }
/** /**
@ -1354,33 +1365,33 @@ class TicCrypto {
if (/^[0-9a-zA-Z\._]+$/.test(b64t)) { if (/^[0-9a-zA-Z\._]+$/.test(b64t)) {
return Buffer.from(this.b64t_to_b64(b64t), 'base64').toString('hex') return Buffer.from(this.b64t_to_b64(b64t), 'base64').toString('hex')
} }
return null return ''
} }
// https://en.wikipedia.org/wiki/Base32 // https://en.wikipedia.org/wiki/Base32
static hex_to_b32 (hex) { static hex_to_b32 (hex) {
if (/^[0-9a-fA-F]+$/.test(hex)) { if (my.REGEXP_ALPHABET.hex.test(hex)) {
return base32encode(Buffer.from(hex, 'hex'), 'RFC4648') return base32encode(Buffer.from(hex, 'hex'), 'RFC4648')
} }
return null return ''
} }
static b32_to_hex (b32) { static b32_to_hex (b32) {
if (/^[A-Za-z2-7=]+$/.test(b32)) { if (my.REGEXP_ALPHABET.b32.test(b32)) {
return Buffer.from(base32decode(b32.toUpperCase(), 'RFC4648')).toString('hex') return Buffer.from(base32decode(b32.toUpperCase(), 'RFC4648')).toString('hex')
} }
return null return ''
} }
static hex_to_b32h (hex) { static hex_to_b32h (hex) {
if (/^[0-9a-fA-F]+$/.test(hex)) { if (my.REGEXP_ALPHABET.hex.test(hex)) {
return base32encode(Buffer.from(hex, 'hex'), 'RFC4648-HEX') return base32encode(Buffer.from(hex, 'hex'), 'RFC4648-HEX')
} }
return null return ''
} }
static b32h_to_hex (b32h) { static b32h_to_hex (b32h) {
if (/^[0-9A-Va-v=]+$/.test(b32h)) { if (my.REGEXP_ALPHABET.b32h.test(b32h)) {
return Buffer.from(base32decode(b32.toUpperCase(), 'RFC4648-HEX')).toString('hex') return Buffer.from(base32decode(b32.toUpperCase(), 'RFC4648-HEX')).toString('hex')
} }
return null return ''
} }
/** /**
@ -1405,7 +1416,7 @@ class TicCrypto {
} }
return result return result
} }
return null return ''
} }
/** /**
@ -1430,7 +1441,7 @@ class TicCrypto {
if (this.decompress_pubkey(compressed) === uncompressed) { if (this.decompress_pubkey(compressed) === uncompressed) {
return compressed return compressed
} }
return null // 非压缩公钥有错误。 return '' // 非压缩公钥有错误。
} }
/** /**
@ -1562,29 +1573,62 @@ class TicCrypto {
ripemd160: '1053', ripemd160: '1053',
md5: 'd5', md5: 'd5',
} }
if (cidVersion === 0) { try {
return this.hex_to_b58(`${multialgo[cidAlgo]}${Number(cosh.length / 2).toString(16)}${cosh}`) if (cidVersion === 0) {
} else if (cidVersion === 1) { return this.hex_to_b58(`${multialgo[cidAlgo]}${Number(cosh.length / 2).toString(16)}${cosh}`)
const fullHex = `01${multicodec[cidCodec]}${multialgo[cidAlgo]}${Number(cosh.length / 2).toString(16)}${cosh}` } else if (cidVersion === 1) {
let converted = '' const fullHex = `01${multicodec[cidCodec]}${multialgo[cidAlgo]}${Number(cosh.length / 2).toString(16)}${cosh}`
if (cidBase === 'b16') { let converted = ''
converted = fullHex.toLowerCase() if (cidBase === 'b16') {
} else if (cidBase === 'B16') { converted = fullHex.toLowerCase()
converted = fullHex.toUpperCase() } else if (cidBase === 'B16') {
} else if (cidBase === 'b32') { converted = fullHex.toUpperCase()
converted = this.hex_to_b32(fullHex).toLowerCase().replace(/=/g, '') } else if (cidBase === 'b32') {
} else if (cidBase === 'B32') { converted = this.hex_to_b32(fullHex)?.toLowerCase?.()?.replace?.(/=/g, '')
converted = this.hex_to_b32(fullHex).toUpperCase().replace(/=/g, '') } else if (cidBase === 'B32') {
} else if (cidBase === 'b58') { converted = this.hex_to_b32(fullHex)?.toUpperCase?.()?.replace?.(/=/g, '')
converted = this.hex_to_b58(fullHex) } else if (cidBase === 'b58') {
} else if (cidBase === 'b64p') { converted = this.hex_to_b58(fullHex)
converted = Buffer.from(fullHex, 'hex').toString('base64') } else if (cidBase === 'b64p') {
} else if (cidBase === 'b64') { converted = Buffer.from(fullHex, 'hex').toString('base64')
converted = Buffer.from(fullHex, 'hex').toString('base64').replace(/=/g, '') } else if (cidBase === 'b64') {
} else if (cidBase === 'b10') { converted = Buffer.from(fullHex, 'hex').toString('base64').replace(/=/g, '')
converted = BigInt('0x' + fullHex).toString() } else if (cidBase === 'b10') {
converted = BigInt('0x' + fullHex).toString()
}
if (converted) {
return multibase[cidBase] + converted
} else {
return ''
}
} }
return multibase[cidBase] + converted } catch {
return ''
}
}
static convert_pexid (key) {
key = key.toLowerCase()
let pextokenCid, pextokenCosh, nftToid
if (key.length < 64 && /^bafkrei/.test(key)) {
pextokenCid = key
pextokenCosh = this.cid_to_cosh({ cid: pextokenCid })
nftToid = BigInt('0x' + pextokenCosh).toString()
} else if (key.length > 64 && /^\d+$/.test(key)) {
nftToid = key
pextokenCosh = BigInt(nftToid).toString(16)
pextokenCid = this.cosh_to_cid({ cosh: pextokenCosh })
} else if (/^[0-9a-f]{64}$/.test(key)) {
pextokenCosh = key
pextokenCid = this.cosh_to_cid({ cosh: pextokenCosh })
nftToid = BigInt('0x' + pextokenCosh).toString()
}
const tokenURI = 'https://ipfs.tic.cc/ipfs/f01551220' + pextokenCosh
return {
pextokenCid,
pextokenCosh,
nftToid,
tokenURI,
} }
} }
} }