[{"data":1,"prerenderedAt":723},["ShallowReactive",2],{"navigation_docs":3,"-guide-keys":72,"-guide-keys-surround":718},[4,32],{"title":5,"path":6,"stem":7,"children":8,"icon":31},"Guide","\u002Fguide","1.guide\u002F1.index",[9,11,15,19,23,27],{"title":10,"path":6,"stem":7},"Getting Started",{"title":12,"path":13,"stem":14},"Working with Keys","\u002Fguide\u002Fkeys","1.guide\u002F2.keys",{"title":16,"path":17,"stem":18},"Working with Addresses","\u002Fguide\u002Faddresses","1.guide\u002F3.addresses",{"title":20,"path":21,"stem":22},"Generating Wallets","\u002Fguide\u002Fwallets","1.guide\u002F4.wallets",{"title":24,"path":25,"stem":26},"Working with EVM Chains","\u002Fguide\u002Fevm","1.guide\u002F5.evm",{"title":28,"path":29,"stem":30},"Creating Custom Blockchains","\u002Fguide\u002Fcustom","1.guide\u002F6.custom","i-lucide-book-open",{"title":33,"path":34,"stem":35,"children":36,"icon":71},"Blockchains","\u002Fblockchains","2.blockchains\u002F0.index",[37,39,43,47,51,55,59,63,67],{"title":38,"path":34,"stem":35},"Overview",{"title":40,"path":41,"stem":42},"Aptos","\u002Fblockchains\u002Faptos","2.blockchains\u002Faptos",{"title":44,"path":45,"stem":46},"Base","\u002Fblockchains\u002Fbase","2.blockchains\u002Fbase",{"title":48,"path":49,"stem":50},"Bitcoin","\u002Fblockchains\u002Fbitcoin","2.blockchains\u002Fbitcoin",{"title":52,"path":53,"stem":54},"Cardano","\u002Fblockchains\u002Fcardano","2.blockchains\u002Fcardano",{"title":56,"path":57,"stem":58},"Ethereum","\u002Fblockchains\u002Fethereum","2.blockchains\u002Fethereum",{"title":60,"path":61,"stem":62},"Solana","\u002Fblockchains\u002Fsolana","2.blockchains\u002Fsolana",{"title":64,"path":65,"stem":66},"Sui","\u002Fblockchains\u002Fsui","2.blockchains\u002Fsui",{"title":68,"path":69,"stem":70},"TRON","\u002Fblockchains\u002Ftron","2.blockchains\u002Ftron","i-lucide-boxes",{"id":73,"title":12,"body":74,"description":711,"extension":712,"links":713,"meta":714,"navigation":158,"path":13,"seo":716,"stem":14,"__hash__":717},"docs\u002F1.guide\u002F2.keys.md",{"type":75,"value":76,"toc":703},"minimark",[77,82,86,238,255,259,309,320,365,368,372,431,438,442,505,508,551,555,562,670,681,685,699],[78,79,81],"h2",{"id":80},"a-private-key","A private key",[83,84,85],"p",{},"Every chain uses the same generator. You get 32 bytes of randomness as a 64 character hex string, nothing more.",[87,88,93],"pre",{"className":89,"code":90,"language":91,"meta":92,"style":92},"language-js shiki shiki-themes github-light github-light poimandres","import { useBlockchain } from \"@agntn\u002Fkeys\";\nimport Bitcoin from \"@agntn\u002Fkeys\u002Fblockchains\u002Fbitcoin\";\n\nconst chain = useBlockchain(new Bitcoin());\nconst privateKey = chain.generateKeyPrivate();\n\nconsole.log(privateKey); \u002F\u002F '7f9e5b9e3bbed34a4c28c8c1665525fc2cd7afb4fdc7edca3eb93ddf8a31ef56'\n","js","",[94,95,96,134,153,160,188,210,215],"code",{"__ignoreMap":92},[97,98,101,105,109,113,116,120,124,128,131],"span",{"class":99,"line":100},"line",1,[97,102,104],{"class":103},"sP0CR","import",[97,106,108],{"class":107},"sKlNE"," {",[97,110,112],{"class":111},"snHMy"," useBlockchain",[97,114,115],{"class":107}," }",[97,117,119],{"class":118},"stCPd"," from",[97,121,123],{"class":122},"scVjq"," \"",[97,125,127],{"class":126},"sQ7BG","@agntn\u002Fkeys",[97,129,130],{"class":122},"\"",[97,132,133],{"class":107},";\n",[97,135,137,139,142,144,146,149,151],{"class":99,"line":136},2,[97,138,104],{"class":103},[97,140,141],{"class":111}," Bitcoin",[97,143,119],{"class":118},[97,145,123],{"class":122},[97,147,148],{"class":126},"@agntn\u002Fkeys\u002Fblockchains\u002Fbitcoin",[97,150,130],{"class":122},[97,152,133],{"class":107},[97,154,156],{"class":99,"line":155},3,[97,157,159],{"emptyLinePlaceholder":158},true,"\n",[97,161,163,167,171,174,177,180,183,185],{"class":99,"line":162},4,[97,164,166],{"class":165},"s1TYA","const",[97,168,170],{"class":169},"saoiD"," chain",[97,172,173],{"class":165}," =",[97,175,112],{"class":176},"sULi6",[97,178,179],{"class":107},"(",[97,181,182],{"class":103},"new",[97,184,141],{"class":176},[97,186,187],{"class":107},"());\n",[97,189,191,193,196,198,201,204,207],{"class":99,"line":190},5,[97,192,166],{"class":165},[97,194,195],{"class":169}," privateKey",[97,197,173],{"class":165},[97,199,170],{"class":200},"spVlQ",[97,202,203],{"class":107},".",[97,205,206],{"class":176},"generateKeyPrivate",[97,208,209],{"class":107},"();\n",[97,211,213],{"class":99,"line":212},6,[97,214,159],{"emptyLinePlaceholder":158},[97,216,218,221,223,226,228,231,234],{"class":99,"line":217},7,[97,219,220],{"class":200},"console",[97,222,203],{"class":107},[97,224,225],{"class":176},"log",[97,227,179],{"class":107},[97,229,230],{"class":200},"privateKey",[97,232,233],{"class":107},"); ",[97,235,237],{"class":236},"sjhu3","\u002F\u002F '7f9e5b9e3bbed34a4c28c8c1665525fc2cd7afb4fdc7edca3eb93ddf8a31ef56'\n",[83,239,240,241,244,245,248,249,254],{},"secp256k1 chains ask ",[94,242,243],{},"@noble\u002Fcurves"," for a key that is guaranteed to sit inside the curve order. ed25519 chains take raw bytes from ",[94,246,247],{},"crypto.getRandomValues",", because any 32 bytes are a valid ed25519 seed. Both work in Node and in the browser, which is what the ",[250,251,253],"a",{"href":252},"\u002Fkeyspace","Keyspace"," explorer relies on.",[78,256,258],{"id":257},"the-public-key","The public key",[87,260,262],{"className":89,"code":261,"language":91,"meta":92,"style":92},"const publicKey = chain.getKeyPublic(privateKey);\n\nconsole.log(publicKey); \u002F\u002F '02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc'\n",[94,263,264,287,291],{"__ignoreMap":92},[97,265,266,268,271,273,275,277,280,282,284],{"class":99,"line":100},[97,267,166],{"class":165},[97,269,270],{"class":169}," publicKey",[97,272,173],{"class":165},[97,274,170],{"class":200},[97,276,203],{"class":107},[97,278,279],{"class":176},"getKeyPublic",[97,281,179],{"class":107},[97,283,230],{"class":200},[97,285,286],{"class":107},");\n",[97,288,289],{"class":99,"line":136},[97,290,159],{"emptyLinePlaceholder":158},[97,292,293,295,297,299,301,304,306],{"class":99,"line":155},[97,294,220],{"class":200},[97,296,203],{"class":107},[97,298,225],{"class":176},[97,300,179],{"class":107},[97,302,303],{"class":200},"publicKey",[97,305,233],{"class":107},[97,307,308],{"class":236},"\u002F\u002F '02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc'\n",[83,310,311,312,315,316,319],{},"On secp256k1 chains this is the compressed form: 33 bytes, starting with ",[94,313,314],{},"02"," or ",[94,317,318],{},"03",". That is what Bitcoin, Ethereum, and TRON expect today. If you need the uncompressed 65 byte key, ask for it:",[87,321,323],{"className":89,"code":322,"language":91,"meta":92,"style":92},"const uncompressed = chain.getKeyPublic(privateKey, { compressed: false });\n\u002F\u002F '04a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc7513...'\n",[94,324,325,360],{"__ignoreMap":92},[97,326,327,329,332,334,336,338,340,342,344,347,350,353,357],{"class":99,"line":100},[97,328,166],{"class":165},[97,330,331],{"class":169}," uncompressed",[97,333,173],{"class":165},[97,335,170],{"class":200},[97,337,203],{"class":107},[97,339,279],{"class":176},[97,341,179],{"class":107},[97,343,230],{"class":200},[97,345,346],{"class":107},", {",[97,348,349],{"class":111}," compressed",[97,351,352],{"class":107},":",[97,354,356],{"class":355},"sNe8j"," false",[97,358,359],{"class":107}," });\n",[97,361,362],{"class":99,"line":136},[97,363,364],{"class":236},"\u002F\u002F '04a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc7513...'\n",[83,366,367],{},"ed25519 chains have no compression flag. The public key is always 32 bytes.",[78,369,371],{"id":370},"both-at-once","Both at once",[87,373,375],{"className":89,"code":374,"language":91,"meta":92,"style":92},"const keyPair = chain.generateKeys();\n\nkeyPair.keys.private;\nkeyPair.keys.public;\n",[94,376,377,395,399,416],{"__ignoreMap":92},[97,378,379,381,384,386,388,390,393],{"class":99,"line":100},[97,380,166],{"class":165},[97,382,383],{"class":169}," keyPair",[97,385,173],{"class":165},[97,387,170],{"class":200},[97,389,203],{"class":107},[97,391,392],{"class":176},"generateKeys",[97,394,209],{"class":107},[97,396,397],{"class":99,"line":136},[97,398,159],{"emptyLinePlaceholder":158},[97,400,401,404,406,409,411,414],{"class":99,"line":155},[97,402,403],{"class":200},"keyPair",[97,405,203],{"class":107},[97,407,408],{"class":200},"keys",[97,410,203],{"class":107},[97,412,413],{"class":200},"private",[97,415,133],{"class":107},[97,417,418,420,422,424,426,429],{"class":99,"line":162},[97,419,403],{"class":200},[97,421,203],{"class":107},[97,423,408],{"class":200},[97,425,203],{"class":107},[97,427,428],{"class":200},"public",[97,430,133],{"class":107},[83,432,433,434,437],{},"The same options apply, so ",[94,435,436],{},"chain.generateKeys({ compressed: false })"," gives you an uncompressed pair.",[78,439,441],{"id":440},"the-shape-you-get-back","The shape you get back",[87,443,447],{"className":444,"code":445,"language":446,"meta":92,"style":92},"language-typescript shiki shiki-themes github-light github-light poimandres","interface Keys {\n  keys: {\n    private: string;\n    public: string;\n  };\n}\n","typescript",[94,448,449,461,471,484,495,500],{"__ignoreMap":92},[97,450,451,454,458],{"class":99,"line":100},[97,452,453],{"class":165},"interface",[97,455,457],{"class":456},"sCrqT"," Keys",[97,459,460],{"class":107}," {\n",[97,462,463,467,469],{"class":99,"line":136},[97,464,466],{"class":465},"s0VbO","  keys",[97,468,352],{"class":165},[97,470,460],{"class":107},[97,472,473,476,478,482],{"class":99,"line":155},[97,474,475],{"class":465},"    private",[97,477,352],{"class":165},[97,479,481],{"class":480},"s8yaW"," string",[97,483,133],{"class":107},[97,485,486,489,491,493],{"class":99,"line":162},[97,487,488],{"class":465},"    public",[97,490,352],{"class":165},[97,492,481],{"class":480},[97,494,133],{"class":107},[97,496,497],{"class":99,"line":190},[97,498,499],{"class":107},"  };\n",[97,501,502],{"class":99,"line":212},[97,503,504],{"class":107},"}\n",[83,506,507],{},"Hex strings everywhere. Sizes by curve:",[509,510,511,527],"table",{},[512,513,514],"thead",{},[515,516,517,521,524],"tr",{},[518,519,520],"th",{},"Curve",[518,522,523],{},"Private",[518,525,526],{},"Public",[528,529,530,542],"tbody",{},[515,531,532,536,539],{},[533,534,535],"td",{},"secp256k1",[533,537,538],{},"64 hex chars",[533,540,541],{},"66 hex chars compressed, 130 uncompressed",[515,543,544,547,549],{},[533,545,546],{},"ed25519",[533,548,538],{},[533,550,538],{},[78,552,554],{"id":553},"sui-speaks-two-curves","Sui speaks two curves",[83,556,557,558,561],{},"Sui accepts ed25519 and secp256k1 keys on the same chain. The private key is the same 32 bytes either way. The ",[94,559,560],{},"scheme"," option decides which curve turns it into a public key:",[87,563,565],{"className":89,"code":564,"language":91,"meta":92,"style":92},"import Sui from \"@agntn\u002Fkeys\u002Fblockchains\u002Fsui\";\n\nconst suiChain = useBlockchain(new Sui());\n\nconst ed25519PublicKey = suiChain.getKeyPublic(privateKey); \u002F\u002F default\nconst secp256k1PublicKey = suiChain.getKeyPublic(privateKey, { scheme: \"secp256k1\" });\n",[94,566,567,585,589,608,612,636],{"__ignoreMap":92},[97,568,569,571,574,576,578,581,583],{"class":99,"line":100},[97,570,104],{"class":103},[97,572,573],{"class":111}," Sui",[97,575,119],{"class":118},[97,577,123],{"class":122},[97,579,580],{"class":126},"@agntn\u002Fkeys\u002Fblockchains\u002Fsui",[97,582,130],{"class":122},[97,584,133],{"class":107},[97,586,587],{"class":99,"line":136},[97,588,159],{"emptyLinePlaceholder":158},[97,590,591,593,596,598,600,602,604,606],{"class":99,"line":155},[97,592,166],{"class":165},[97,594,595],{"class":169}," suiChain",[97,597,173],{"class":165},[97,599,112],{"class":176},[97,601,179],{"class":107},[97,603,182],{"class":103},[97,605,573],{"class":176},[97,607,187],{"class":107},[97,609,610],{"class":99,"line":162},[97,611,159],{"emptyLinePlaceholder":158},[97,613,614,616,619,621,623,625,627,629,631,633],{"class":99,"line":190},[97,615,166],{"class":165},[97,617,618],{"class":169}," ed25519PublicKey",[97,620,173],{"class":165},[97,622,595],{"class":200},[97,624,203],{"class":107},[97,626,279],{"class":176},[97,628,179],{"class":107},[97,630,230],{"class":200},[97,632,233],{"class":107},[97,634,635],{"class":236},"\u002F\u002F default\n",[97,637,638,640,643,645,647,649,651,653,655,657,660,662,664,666,668],{"class":99,"line":212},[97,639,166],{"class":165},[97,641,642],{"class":169}," secp256k1PublicKey",[97,644,173],{"class":165},[97,646,595],{"class":200},[97,648,203],{"class":107},[97,650,279],{"class":176},[97,652,179],{"class":107},[97,654,230],{"class":200},[97,656,346],{"class":107},[97,658,659],{"class":111}," scheme",[97,661,352],{"class":107},[97,663,123],{"class":122},[97,665,535],{"class":126},[97,667,130],{"class":122},[97,669,359],{"class":107},[83,671,672,673,676,677,680],{},"Pick the scheme once and carry it through to ",[94,674,675],{},"getAddress",", otherwise the address will not match the key. The ",[250,678,679],{"href":65},"Sui page"," shows the full round trip.",[78,682,684],{"id":683},"under-the-hood","Under the hood",[83,686,687,688,690,691,694,695,698],{},"Curves come from ",[94,689,243],{},", hashes from ",[94,692,693],{},"@noble\u002Fhashes",". There is no second crypto implementation anywhere in the package, and adding one is the first thing a review would reject. EVM chains share everything through ",[94,696,697],{},"AbstractEVMBlockchain",", so Ethereum and Base are the same code with a different name and coin type.",[700,701,702],"style",{},"html pre.shiki code .sP0CR, html code.shiki .sP0CR{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#5DE4C7}html pre.shiki code .sKlNE, html code.shiki .sKlNE{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#A6ACCD}html pre.shiki code .snHMy, html code.shiki .snHMy{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#ADD7FF}html pre.shiki code .stCPd, html code.shiki .stCPd{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#A6ACCD}html pre.shiki code .scVjq, html code.shiki .scVjq{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#A6ACCD}html pre.shiki code .sQ7BG, html code.shiki .sQ7BG{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#5DE4C7}html pre.shiki code .s1TYA, html code.shiki .s1TYA{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#91B4D5}html pre.shiki code .saoiD, html code.shiki .saoiD{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#E4F0FB}html pre.shiki code .sULi6, html code.shiki .sULi6{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#E4F0FBD0}html pre.shiki code .spVlQ, html code.shiki .spVlQ{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E4F0FB}html pre.shiki code .sjhu3, html code.shiki .sjhu3{--shiki-light:#6A737D;--shiki-light-font-style:inherit;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#767C9DB0;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sNe8j, html code.shiki .sNe8j{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#D0679D}html pre.shiki code .sCrqT, html code.shiki .sCrqT{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#A6ACCDC0}html pre.shiki code .s0VbO, html code.shiki .s0VbO{--shiki-light:#E36209;--shiki-default:#E36209;--shiki-dark:#A6ACCD}html pre.shiki code .s8yaW, html code.shiki .s8yaW{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#A6ACCDC0}",{"title":92,"searchDepth":136,"depth":136,"links":704},[705,706,707,708,709,710],{"id":80,"depth":136,"text":81},{"id":257,"depth":136,"text":258},{"id":370,"depth":136,"text":371},{"id":440,"depth":136,"text":441},{"id":553,"depth":136,"text":554},{"id":683,"depth":136,"text":684},"Private keys, public keys, compression, and the one chain that speaks two curves.","md",null,{"icon":715},"i-lucide-key",{"title":12,"description":711},"7FpT-glWFUgL-x0mR9gIknJ4U00g9lVljqc3Zt-1UCk",[719,721],{"title":10,"path":6,"stem":7,"description":720,"children":-1},"Install the package, load a chain, and get a wallet out in five lines.",{"title":16,"path":17,"stem":18,"description":722,"children":-1},"Turn a public key into an address, pick a format, and check one you were given.",1788428715659]