[{"data":1,"prerenderedAt":476},["ShallowReactive",2],{"navigation_docs":3,"-math-curves":44,"-math-curves-surround":471},[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":32,"body":46,"description":464,"extension":465,"links":466,"meta":467,"navigation":92,"path":33,"seo":469,"stem":34,"__hash__":470},"docs\u002F2.math\u002F01.curves.md",{"type":47,"value":48,"toc":458},"minimark",[49,54,130,134,142,149,153,315,321,325,331,337,340,344,358,448,454],[50,51,53],"h2",{"id":52},"define-the-curve","Define the curve",[55,56,61],"pre",{"className":57,"code":58,"language":59,"meta":60,"style":60},"language-ts shiki shiki-themes compressions compressions compressions","import { defineCurve } from \"@agntn\u002Fcurves\";\n\ndefineCurve({ a: -3n, b: 20n, p: 17n }); \u002F\u002F { a: 14n, b: 3n, p: 17n }\n","ts","",[62,63,64,87,94],"code",{"__ignoreMap":60},[65,66,69,73,77,80,84],"span",{"class":67,"line":68},"line",1,[65,70,72],{"class":71},"skH_V","import",[65,74,76],{"class":75},"s38Sx"," { defineCurve } ",[65,78,79],{"class":71},"from",[65,81,83],{"class":82},"shU9J"," \"@agntn\u002Fcurves\"",[65,85,86],{"class":75},";\n",[65,88,90],{"class":67,"line":89},2,[65,91,93],{"emptyLinePlaceholder":92},true,"\n",[65,95,97,101,104,107,110,113,116,118,121,123,126],{"class":67,"line":96},3,[65,98,100],{"class":99},"sK71F","defineCurve",[65,102,103],{"class":75},"({ a: ",[65,105,106],{"class":71},"-",[65,108,109],{"class":75},"3",[65,111,112],{"class":71},"n",[65,114,115],{"class":75},", b: 20",[65,117,112],{"class":71},[65,119,120],{"class":75},", p: 17",[65,122,112],{"class":71},[65,124,125],{"class":75}," }); ",[65,127,129],{"class":128},"scIB-","\u002F\u002F { a: 14n, b: 3n, p: 17n }\n",[131,132,133],"p",{},"a and b take any integer and come back reduced mod p. So a = -3 works and turns into 14. p has to be a prime above 3, checked with Baillie-PSW. And the curve can't be singular, so 4a³ + 27b² mod p can't be 0.",[55,135,140],{"className":136,"code":138,"language":139,"meta":60},[137],"language-text","defineCurve({ a: 0n, b: 0n, p: 17n })   \u002F\u002F The curve is singular: 4a^3 + 27b^2 is 0 mod p\ndefineCurve({ a: 1n, b: 1n, p: 21n })   \u002F\u002F p must be a prime above 3\n","text",[62,141,138],{"__ignoreMap":60},[131,143,144,145,148],{},"The result is frozen and remembered. Every other function takes it without checking it again. Plain ",[62,146,147],{},"{ a, b, p }"," works too, it just gets checked on every call.",[50,150,152],{"id":151},"arithmetic","Arithmetic",[55,154,156],{"className":57,"code":155,"language":59,"meta":60,"style":60},"import { addPoints, doublePoint, multiplyPoint, negatePoint } from \"@agntn\u002Fcurves\";\n\nconst curve = defineCurve({ a: 2n, b: 2n, p: 17n });\nconst G = { x: 5n, y: 1n };\n\ndoublePoint(curve, G); \u002F\u002F { x: 6n, y: 3n }\naddPoints(curve, G, { x: 6n, y: 3n }); \u002F\u002F { x: 10n, y: 6n }\nnegatePoint(curve, G); \u002F\u002F { x: 5n, y: 16n }\nmultiplyPoint(curve, G, 19n); \u002F\u002F null\nmultiplyPoint(curve, G, -2n); \u002F\u002F { x: 6n, y: 14n }\n",[62,157,158,171,175,206,229,234,246,267,278,295],{"__ignoreMap":60},[65,159,160,162,165,167,169],{"class":67,"line":68},[65,161,72],{"class":71},[65,163,164],{"class":75}," { addPoints, doublePoint, multiplyPoint, negatePoint } ",[65,166,79],{"class":71},[65,168,83],{"class":82},[65,170,86],{"class":75},[65,172,173],{"class":67,"line":89},[65,174,93],{"emptyLinePlaceholder":92},[65,176,177,180,183,186,189,192,194,197,199,201,203],{"class":67,"line":96},[65,178,179],{"class":71},"const",[65,181,182],{"class":75}," curve ",[65,184,185],{"class":71},"=",[65,187,188],{"class":99}," defineCurve",[65,190,191],{"class":75},"({ a: 2",[65,193,112],{"class":71},[65,195,196],{"class":75},", b: 2",[65,198,112],{"class":71},[65,200,120],{"class":75},[65,202,112],{"class":71},[65,204,205],{"class":75}," });\n",[65,207,209,211,214,216,219,221,224,226],{"class":67,"line":208},4,[65,210,179],{"class":71},[65,212,213],{"class":75}," G ",[65,215,185],{"class":71},[65,217,218],{"class":75}," { x: 5",[65,220,112],{"class":71},[65,222,223],{"class":75},", y: 1",[65,225,112],{"class":71},[65,227,228],{"class":75}," };\n",[65,230,232],{"class":67,"line":231},5,[65,233,93],{"emptyLinePlaceholder":92},[65,235,237,240,243],{"class":67,"line":236},6,[65,238,239],{"class":99},"doublePoint",[65,241,242],{"class":75},"(curve, G); ",[65,244,245],{"class":128},"\u002F\u002F { x: 6n, y: 3n }\n",[65,247,249,252,255,257,260,262,264],{"class":67,"line":248},7,[65,250,251],{"class":99},"addPoints",[65,253,254],{"class":75},"(curve, G, { x: 6",[65,256,112],{"class":71},[65,258,259],{"class":75},", y: 3",[65,261,112],{"class":71},[65,263,125],{"class":75},[65,265,266],{"class":128},"\u002F\u002F { x: 10n, y: 6n }\n",[65,268,270,273,275],{"class":67,"line":269},8,[65,271,272],{"class":99},"negatePoint",[65,274,242],{"class":75},[65,276,277],{"class":128},"\u002F\u002F { x: 5n, y: 16n }\n",[65,279,281,284,287,289,292],{"class":67,"line":280},9,[65,282,283],{"class":99},"multiplyPoint",[65,285,286],{"class":75},"(curve, G, 19",[65,288,112],{"class":71},[65,290,291],{"class":75},"); ",[65,293,294],{"class":128},"\u002F\u002F null\n",[65,296,298,300,303,305,308,310,312],{"class":67,"line":297},10,[65,299,283],{"class":99},[65,301,302],{"class":75},"(curve, G, ",[65,304,106],{"class":71},[65,306,307],{"class":75},"2",[65,309,112],{"class":71},[65,311,291],{"class":75},[65,313,314],{"class":128},"\u002F\u002F { x: 6n, y: 14n }\n",[131,316,317,320],{},[62,318,319],{},"null"," is the point at infinity, and it goes in too. A negative scalar multiplies the negation. Zero gives infinity.",[50,322,324],{"id":323},"checking-a-point","Checking a point",[131,326,327,330],{},[62,328,329],{},"isOnCurve"," answers true or false. Every other function refuses a point off the curve before it touches it:",[55,332,335],{"className":333,"code":334,"language":139,"meta":60},[137],"isOnCurve(curve, { x: 5n, y: 2n })     \u002F\u002F false\ndoublePoint(curve, { x: 5n, y: 2n })   \u002F\u002F RangeError: The point is not on the curve; coordinates run from 0 to p minus 1\n",[62,336,334],{"__ignoreMap":60},[131,338,339],{},"Why so strict? An invalid curve attack starts exactly there. Feed a point from another curve and you get answers on that curve, quietly. Here you get an error.",[50,341,343],{"id":342},"over-mcp","Over MCP",[131,345,346,349,350,353,354,357],{},[62,347,348],{},"curves_compute"," takes the same thing as strings. Points are ",[62,351,352],{},"{ \"x\": \"5\", \"y\": \"1\" }",", integers decimal or ",[62,355,356],{},"0x"," hex:",[55,359,363],{"className":360,"code":361,"language":362,"meta":60,"style":60},"language-json shiki shiki-themes compressions compressions compressions","{ \"operation\": \"multiply\", \"a\": \"2\", \"b\": \"2\", \"p\": \"17\", \"point\": { \"x\": \"5\", \"y\": \"1\" }, \"scalar\": \"2\" }\n","json",[62,364,365],{"__ignoreMap":60},[65,366,367,370,373,376,379,382,385,387,390,392,395,397,399,401,404,406,409,411,414,417,420,422,425,427,430,432,435,438,441,443,445],{"class":67,"line":68},[65,368,369],{"class":75},"{ ",[65,371,372],{"class":99},"\"operation\"",[65,374,375],{"class":75},": ",[65,377,378],{"class":82},"\"multiply\"",[65,380,381],{"class":75},", ",[65,383,384],{"class":99},"\"a\"",[65,386,375],{"class":75},[65,388,389],{"class":82},"\"2\"",[65,391,381],{"class":75},[65,393,394],{"class":99},"\"b\"",[65,396,375],{"class":75},[65,398,389],{"class":82},[65,400,381],{"class":75},[65,402,403],{"class":99},"\"p\"",[65,405,375],{"class":75},[65,407,408],{"class":82},"\"17\"",[65,410,381],{"class":75},[65,412,413],{"class":99},"\"point\"",[65,415,416],{"class":75},": { ",[65,418,419],{"class":99},"\"x\"",[65,421,375],{"class":75},[65,423,424],{"class":82},"\"5\"",[65,426,381],{"class":75},[65,428,429],{"class":99},"\"y\"",[65,431,375],{"class":75},[65,433,434],{"class":82},"\"1\"",[65,436,437],{"class":75}," }, ",[65,439,440],{"class":99},"\"scalar\"",[65,442,375],{"class":75},[65,444,389],{"class":82},[65,446,447],{"class":75}," }\n",[55,449,452],{"className":450,"code":451,"language":139,"meta":60},[137],"{\"operation\":\"multiply\",\"point\":{\"x\":\"6\",\"y\":\"3\"}}\n",[62,453,451],{"__ignoreMap":60},[455,456,457],"style",{},"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 .shU9J, html code.shiki .shU9J{--shiki-light:var(--shiki-token-string);--shiki-default:var(--shiki-token-string);--shiki-dark:var(--shiki-token-string)}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 .scIB-, html code.shiki .scIB-{--shiki-light:var(--shiki-token-comment);--shiki-default:var(--shiki-token-comment);--shiki-dark:var(--shiki-token-comment)}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);}",{"title":60,"searchDepth":89,"depth":89,"links":459},[460,461,462,463],{"id":52,"depth":89,"text":53},{"id":151,"depth":89,"text":152},{"id":323,"depth":89,"text":324},{"id":342,"depth":89,"text":343},"Define a short Weierstrass curve over a prime and add and double and negate and multiply its points","md",null,{"icon":468},"i-lucide-spline",{"title":32,"description":464},"K_3mWbpU5fiy42aBFEs3C94mW4yAsBAJC7F4iqxMyQo",[472,474],{"title":30,"path":26,"stem":27,"description":473,"children":-1},"What the package computes. Short Weierstrass curves over a prime you pick and secp256k1 on its own",{"title":36,"path":37,"stem":38,"description":475,"children":-1},"Count and list the points of a curve and find the order of a point and a discrete log by baby step giant step",1791298463174]