{"uid":"cap_eAlvNcsNz01g9aO9bgSAi","slug":"crypto-math-modular-multiplicative-inverse-87efc29e","name":"Crypto Math: Modular Multiplicative Inverse","description":"Modular multiplicative inverse of a mod m, or the gcd that proves none exists.","url":"https://crypto-math.x402tookit.com/mod-inverse?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":["a","mod"],"properties":{"a":{"type":"string","description":"Number to invert, whole number (decimal or 0x hex)"},"mod":{"type":"string","description":"Modulus, whole number of at least 2"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"gcd":{"type":["null","object"],"properties":{"hex":{"type":["null","string"]},"bits":{"type":["null","number"]},"decimal":{"type":["null","string"]}}},"asOf":{"type":["null","string"]},"check":{"type":["null","string"]},"result":{"type":["null","object"],"properties":{"hex":{"type":["null","string"]},"bits":{"type":["null","number"]},"decimal":{"type":["null","string"]}}},"source":{"type":["null","string"]},"reasons":{"type":["array","null"],"items":{"type":"string"}},"summary":{"type":["null","string"]},"verdict":{"type":["null","string"]},"degraded":{"type":["boolean","null"]},"disclaimer":{"type":["null","string"]},"notChecked":{"type":["array","null"],"items":{"type":"string"}}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_QO0zFMRlCpSijvW-MLXtG","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes the modular multiplicative inverse of a mod m, or returns the GCD proving no inverse exists when gcd(a,m) > 1.","exampleAgentPrompt":"What is the modular multiplicative inverse of 17 mod 3120? If it doesn't exist, tell me the GCD that proves it.","exampleUseCases":[{"title":"RSA private exponent computation","prompt":"I need to find the modular inverse of my public exponent e=65537 mod phi(n), where phi(n) is 7905853580. That will be my RSA private exponent d — can you compute it?"},{"title":"Elliptic curve scalar inversion","prompt":"For a secp256k1 point scalar operation I need the modular inverse of 0x3f2d1a9b mod the curve order 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141. Can you compute that?"},{"title":"Checking invertibility before cryptographic step","prompt":"Before I proceed with my protocol, I need to know: does 42 have a modular inverse mod 100? If not, give me the GCD that shows why it's impossible."}],"resultDescription":"Returns a JSON object with a 'result' field containing the modular inverse (in decimal, hex, and bit-length), a 'gcd' field (null if gcd=1, otherwise the GCD value showing why no inverse exists), a 'verdict' string, a human-readable 'summary', and optional 'check' and 'reasons' fields. The 'degraded' flag indicates if the result is partial.","failureModes":["Missing required parameter 'a' or 'mod' returns an error","Modulus less than 2 is rejected as invalid","Non-integer or malformed hex input causes a parse error","When gcd(a,m) > 1, no inverse exists and the response returns the GCD instead of a result","Very large integers may exceed bit-size limits"],"whenToPreferThis":"Choose this endpoint when you need to compute a modular multiplicative inverse for cryptographic or number-theoretic purposes — especially for RSA key derivation, elliptic curve scalar inversion, or any modular arithmetic where you also want confirmation that the inverse is valid (gcd=1). It handles both decimal and 0x hex inputs and explicitly returns the GCD when no inverse exists, making it useful for pre-flight checks in cryptographic protocols.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-30T00:30:45.878Z","isFirstParty":false,"canonicalSlug":"crypto-math-modular-multiplicative-inverse-87efc29e"}