[{"data":1,"prerenderedAt":376},["ShallowReactive",2],{"navigation_docs":3,"-guide":44,"-guide-surround":373},[4,24],{"title":5,"path":6,"stem":7,"children":8,"icon":23},"Guide","\u002Fguide","1.guide\u002F01.index",[9,11,15,19],{"title":10,"path":6,"stem":7},"Getting started",{"title":12,"path":13,"stem":14},"CLI","\u002Fguide\u002Fcli","1.guide\u002F02.cli",{"title":16,"path":17,"stem":18},"Agents","\u002Fguide\u002Fagents","1.guide\u002F03.agents",{"title":20,"path":21,"stem":22},"Playground","\u002Fguide\u002Fplayground","1.guide\u002F04.playground","i-lucide-book-open",{"title":25,"path":26,"stem":27,"children":28,"icon":43},"Math","\u002Fmath","2.math\u002F00.index",[29,31,35,39],{"title":30,"path":26,"stem":27},"Overview",{"title":32,"path":33,"stem":34},"Curves and points","\u002Fmath\u002Fcurves","2.math\u002F01.curves",{"title":36,"path":37,"stem":38},"Orders and logs","\u002Fmath\u002Fgroups","2.math\u002F02.groups",{"title":40,"path":41,"stem":42},"secp256k1","\u002Fmath\u002Fsecp256k1","2.math\u002F03.secp256k1","i-lucide-sigma",{"id":45,"title":10,"body":46,"description":366,"extension":367,"links":368,"meta":369,"navigation":370,"path":6,"seo":371,"stem":7,"__hash__":372},"docs\u002F1.guide\u002F01.index.md",{"type":47,"value":48,"toc":360},"minimark",[49,54,80,88,93,97,100,237,244,259,263,266,321,324,328,356],[50,51,53],"h2",{"id":52},"install-it","Install it",[55,56,61],"pre",{"className":57,"code":58,"language":59,"meta":60,"style":60},"language-bash shiki shiki-themes compressions compressions compressions","pnpm add @agntn\u002Fcurves\n","bash","",[62,63,64],"code",{"__ignoreMap":60},[65,66,69,73,77],"span",{"class":67,"line":68},"line",1,[65,70,72],{"class":71},"sK71F","pnpm",[65,74,76],{"class":75},"shU9J"," add",[65,78,79],{"class":75}," @agntn\u002Fcurves\n",[81,82,83,84,87],"p",{},"Node.js 26 or newer. One install gets you the library, the ",[62,85,86],{},"curves"," CLI and the MCP server. Nothing to configure.",[89,90,92],"caution",{"title":91},"Not audited","This code has never had a security audit. Do not use it in production, with real funds or with sensitive data. It is meant for agents, puzzles and local experiments only. Nothing here runs in constant time.",[50,94,96],{"id":95},"your-first-curve","Your first curve",[81,98,99],{},"A curve here is y² = x³ + ax + b over the integers mod a prime p. Hand over a, b and p:",[55,101,105],{"className":102,"code":103,"language":104,"meta":60,"style":60},"language-ts shiki shiki-themes compressions compressions compressions","import { countPoints, defineCurve, discreteLog, multiplyPoint } from \"@agntn\u002Fcurves\";\n\nconst curve = defineCurve({ a: 2n, b: 2n, p: 17n });\ncountPoints(curve); \u002F\u002F 19n\nmultiplyPoint(curve, { x: 5n, y: 1n }, 2n); \u002F\u002F { x: 6n, y: 3n }\ndiscreteLog(curve, { x: 5n, y: 1n }, { x: 16n, y: 4n }); \u002F\u002F 13n\n","ts",[62,106,107,126,133,167,180,207],{"__ignoreMap":60},[65,108,109,113,117,120,123],{"class":67,"line":68},[65,110,112],{"class":111},"skH_V","import",[65,114,116],{"class":115},"s38Sx"," { countPoints, defineCurve, discreteLog, multiplyPoint } ",[65,118,119],{"class":111},"from",[65,121,122],{"class":75}," \"@agntn\u002Fcurves\"",[65,124,125],{"class":115},";\n",[65,127,129],{"class":67,"line":128},2,[65,130,132],{"emptyLinePlaceholder":131},true,"\n",[65,134,136,139,142,145,148,151,154,157,159,162,164],{"class":67,"line":135},3,[65,137,138],{"class":111},"const",[65,140,141],{"class":115}," curve ",[65,143,144],{"class":111},"=",[65,146,147],{"class":71}," defineCurve",[65,149,150],{"class":115},"({ a: 2",[65,152,153],{"class":111},"n",[65,155,156],{"class":115},", b: 2",[65,158,153],{"class":111},[65,160,161],{"class":115},", p: 17",[65,163,153],{"class":111},[65,165,166],{"class":115}," });\n",[65,168,170,173,176],{"class":67,"line":169},4,[65,171,172],{"class":71},"countPoints",[65,174,175],{"class":115},"(curve); ",[65,177,179],{"class":178},"scIB-","\u002F\u002F 19n\n",[65,181,183,186,189,191,194,196,199,201,204],{"class":67,"line":182},5,[65,184,185],{"class":71},"multiplyPoint",[65,187,188],{"class":115},"(curve, { x: 5",[65,190,153],{"class":111},[65,192,193],{"class":115},", y: 1",[65,195,153],{"class":111},[65,197,198],{"class":115}," }, 2",[65,200,153],{"class":111},[65,202,203],{"class":115},"); ",[65,205,206],{"class":178},"\u002F\u002F { x: 6n, y: 3n }\n",[65,208,210,213,215,217,219,221,224,226,229,231,234],{"class":67,"line":209},6,[65,211,212],{"class":71},"discreteLog",[65,214,188],{"class":115},[65,216,153],{"class":111},[65,218,193],{"class":115},[65,220,153],{"class":111},[65,222,223],{"class":115}," }, { x: 16",[65,225,153],{"class":111},[65,227,228],{"class":115},", y: 4",[65,230,153],{"class":111},[65,232,233],{"class":115}," }); ",[65,235,236],{"class":178},"\u002F\u002F 13n\n",[81,238,239,240,243],{},"That's the textbook curve from Paar and Pelzl. Nineteen points with infinity. And (16, 4) is 13 times (5, 1). Want to see all nineteen? ",[62,241,242],{},"listPoints(curve)"," gives them by x, then y.",[81,245,246,247,250,251,254,255,258],{},"Everything is a ",[62,248,249],{},"bigint",". The point at infinity is ",[62,252,253],{},"null",". A point off the curve throws a ",[62,256,257],{},"RangeError"," before any arithmetic runs on it.",[50,260,262],{"id":261},"or-secp256k1","Or secp256k1",[81,264,265],{},"The real curve lives in its own entry, with points as SEC1 hex:",[55,267,269],{"className":102,"code":268,"language":104,"meta":60,"style":60},"import { liftX, multiplyGenerator } from \"@agntn\u002Fcurves\u002Fsecp256k1\";\n\nmultiplyGenerator(\"03\"); \u002F\u002F \"02f9308a019258c3…36f9\"\nliftX(\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\").odd; \u002F\u002F \"0379be66…1798\"\n",[62,270,271,285,289,305],{"__ignoreMap":60},[65,272,273,275,278,280,283],{"class":67,"line":68},[65,274,112],{"class":111},[65,276,277],{"class":115}," { liftX, multiplyGenerator } ",[65,279,119],{"class":111},[65,281,282],{"class":75}," \"@agntn\u002Fcurves\u002Fsecp256k1\"",[65,284,125],{"class":115},[65,286,287],{"class":67,"line":128},[65,288,132],{"emptyLinePlaceholder":131},[65,290,291,294,297,300,302],{"class":67,"line":135},[65,292,293],{"class":71},"multiplyGenerator",[65,295,296],{"class":115},"(",[65,298,299],{"class":75},"\"03\"",[65,301,203],{"class":115},[65,303,304],{"class":178},"\u002F\u002F \"02f9308a019258c3…36f9\"\n",[65,306,307,310,312,315,318],{"class":67,"line":169},[65,308,309],{"class":71},"liftX",[65,311,296],{"class":115},[65,313,314],{"class":75},"\"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"",[65,316,317],{"class":115},").odd; ",[65,319,320],{"class":178},"\u002F\u002F \"0379be66…1798\"\n",[81,322,323],{},"The generic code and secp256k1 never mix. Importing one doesn't load the other.",[50,325,327],{"id":326},"from-here","From here",[329,330,331,338,343,348],"ul",{},[332,333,334,337],"li",{},[335,336,32],"a",{"href":33},": defining a curve and doing arithmetic on it.",[332,339,340,342],{},[335,341,36],{"href":37},": counting, listing, orders, discrete logs and their limits.",[332,344,345,347],{},[335,346,40],{"href":41},": SEC1 points, scalars mod n, lifting x.",[332,349,350,352,353,355],{},[335,351,12],{"href":13}," and ",[335,354,16],{"href":17},": the same math from a terminal or a model.",[357,358,359],"style",{},"html pre.shiki code .sK71F, html code.shiki .sK71F{--shiki-light:var(--shiki-token-function);--shiki-default:var(--shiki-token-function);--shiki-dark:var(--shiki-token-function)}html pre.shiki code .shU9J, html code.shiki .shU9J{--shiki-light:var(--shiki-token-string);--shiki-default:var(--shiki-token-string);--shiki-dark:var(--shiki-token-string)}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 .skH_V, html code.shiki .skH_V{--shiki-light:var(--shiki-token-keyword);--shiki-default:var(--shiki-token-keyword);--shiki-dark:var(--shiki-token-keyword)}html pre.shiki code .s38Sx, html code.shiki .s38Sx{--shiki-light:var(--ui-text-highlighted);--shiki-default:var(--ui-text-highlighted);--shiki-dark:var(--ui-text-highlighted)}html pre.shiki code .scIB-, html code.shiki .scIB-{--shiki-light:var(--shiki-token-comment);--shiki-default:var(--shiki-token-comment);--shiki-dark:var(--shiki-token-comment)}",{"title":60,"searchDepth":128,"depth":128,"links":361},[362,363,364,365],{"id":52,"depth":128,"text":53},{"id":95,"depth":128,"text":96},{"id":261,"depth":128,"text":262},{"id":326,"depth":128,"text":327},"Install @agntn\u002Fcurves and define a curve and count its points and find a discrete log in a few lines","md",null,{},{"title":10},{"title":10,"description":366},"mxF6t-94lkT5LrDKlFzPMV3vzwl4GYw399wRNARzHr8",[368,374],{"title":12,"path":13,"stem":14,"description":375,"children":-1},"The curves command runs both tools from a terminal and prints the same JSON a model gets",1791293523357]