{"id":51509526,"url":"https://github.com/murphsicles/secp256k1","last_synced_at":"2026-07-08T04:30:58.328Z","repository":{"id":358482331,"uuid":"1240888703","full_name":"murphsicles/secp256k1","owner":"murphsicles","description":"Zeta port of secp256k1","archived":false,"fork":false,"pushed_at":"2026-05-17T15:13:39.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-17T17:31:31.915Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/murphsicles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-16T17:39:17.000Z","updated_at":"2026-05-17T15:13:42.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/murphsicles/secp256k1","commit_stats":null,"previous_names":["murphsicles/secp256k1"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/murphsicles/secp256k1","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphsicles%2Fsecp256k1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphsicles%2Fsecp256k1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphsicles%2Fsecp256k1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphsicles%2Fsecp256k1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/murphsicles","download_url":"https://codeload.github.com/murphsicles/secp256k1/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/murphsicles%2Fsecp256k1/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35252324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-08T02:00:06.796Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-07-08T04:30:57.395Z","updated_at":"2026-07-08T04:30:58.322Z","avatar_url":"https://github.com/murphsicles.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# @crypto/secp256k1\n\n[![@crypto/secp256k1](https://img.shields.io/badge/zorb-%40crypto%2Fsecp256k1-blue)](https://zorbs.io)\n\n**Elliptic curve secp256k1 for Zeta — ECDSA signing, verification, key generation**\n\nPorted from [rust-secp256k1 v0.31.1](https://github.com/rust-bitcoin/rust-secp256k1).\n\nThe cryptographic foundation of Bitcoin, BSV, and the entire BSV ecosystem. This crate provides ECDSA operations on the **secp256k1** curve (`y² = x³ + 7`), giving your Zeta applications the power to create and verify digital signatures.\n\n## Why secp256k1?\n\nEvery transaction on the BSV blockchain starts and ends with an ECDSA signature:\n\n- 🔑 **Key generation** — create new wallets and identities\n- ✍️ **Signing** — authorize transactions, sign messages\n- ✅ **Verification** — validate signatures from other parties\n- 🔄 **Public key recovery** — extract the signer's public key from a signature\n- 🤝 **Multi-signature** — aggregate keys for shared control\n\n## Installation\n\n```toml\n[dependencies]\n\"@crypto/secp256k1\" = \"0.31.1\"\n```\n\n## Usage\n\n```zeta\nconst secp = @import(\"@crypto/secp256k1\");\n\n// Create signing context\nconst ctx = secp.Secp256k1::new();\n\n// Generate a keypair\nconst (sk, pk) = ctx.generate_keypair();\n\n// Create a message to sign\nconst msg = secp.Message::from_bytes([0xabu8; 32]);\n\n// Sign the message\nconst sig = try ctx.sign(\u0026msg, \u0026sk);\n\n// Verify the signature\nconst valid = try ctx.verify(\u0026msg, \u0026sig, \u0026pk);\nstd.log.info(\"signature valid: {}\", [.valid]);\n\n// Recover public key from signature\nconst recovered = try ctx.recover(\u0026msg, \u0026sig);\nstd.log.info(\"recovered matches: {}\", [.recovered.serialize() == pk.serialize()]);\n```\n\n## API\n\n### Types\n\n| Type | Size | Description |\n|------|------|-------------|\n| `Secp256k1` | — | Signing/verification context |\n| `PublicKey` | 33B | Compressed public key (02/03 + X) |\n| `SecretKey` | 32B | Private scalar |\n| `Signature` | 72B | DER-encoded ECDSA signature |\n| `Message` | 32B | Message hash to sign |\n| `SecpError` | — | Error type for crypto operations |\n\n### Secp256k1 Methods\n\n| Method | Description |\n|--------|-------------|\n| `new()` | Create context |\n| `generate_keypair()` | Random keypair generation |\n| `sign(msg, sk)` | Create ECDSA signature |\n| `verify(msg, sig, pk)` | Verify ECDSA signature |\n| `recover(msg, sig)` | Recover public key from signature |\n| `aggregate_pubkeys(pks)` | Aggregate multiple public keys |\n\n### Key Operations\n\n| Method | Description |\n|--------|-------------|\n| `PublicKey::from_bytes()` | Create from compressed bytes |\n| `PublicKey::from_uncompressed()` | Create from uncompressed bytes |\n| `PublicKey::serialize()` | To compressed 33 bytes |\n| `PublicKey::serialize_uncompressed()` | To uncompressed 65 bytes |\n| `PublicKey::x_coord()` | Extract X coordinate |\n| `SecretKey::from_bytes()` | Create from 32 bytes |\n| `SecretKey::serialize()` | To 32 bytes |\n| `SecretKey::public_key()` | Derive corresponding public key |\n| `SecretKey::add_tweak()` | Add tweak to secret key |\n| `SecretKey::mul_tweak()` | Multiply secret key by tweak |\n| `Signature::from_der()` | Create from DER bytes |\n| `Signature::from_compact()` | Create from compact 64 bytes |\n| `Signature::serialize_der()` | To DER format |\n| `Signature::serialize_compact()` | To compact format (R \\|\\| S) |\n| `Message::from_bytes()` | Create from 32 bytes |\n| `Message::from_sha256()` | Create by SHA-256 hashing data |\n| `Message::from_double_sha256()` | Create by double-SHA-256 hashing data |\n\n### Free Functions\n\n| Function | Description |\n|----------|-------------|\n| `is_valid_scalar(bytes)` | Check if bytes form valid scalar |\n| `is_valid_pubkey(bytes)` | Check if bytes form valid pubkey |\n| `pubkey_x_only(pk)` | Get X coordinate for hashing |\n| `negate_secret(sk)` | Negate a secret key |\n| `tweak_pubkey(pk, tweak)` | BIP32 pubkey tweaking |\n\n## nour / Dark Factory Integration\n\nThis crate is the **crypto backbone** for the nour BSV toolkit. Every operation that touches BSV — from wallet creation to transaction signing to signature validation — depends on secp256k1.\n\n### Transaction Signing Flow\n\n```\nWallet SecretKey\n    ↓\nsign(tx_hash, sk) → Signature\n    ↓\nTransaction broadcast\n    ↓\nFull nodes verify(tx_hash, sig, pk)\n    ↓\n✓ Transaction confirmed\n```\n\n## The secp256k1 Curve\n\n- **Equation:** `y² = x³ + 7`\n- **Order (n):** `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141`\n- **Prime (p):** `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F`\n- **Generator (G):** Standard base point for the curve\n\n## Safety\n\nThis crate delegates to the Zeta runtime's cryptographic primitives. The runtime handles constant-time operations, side-channel protection, and memory zeroization.\n\n## License\n\nMIT — see [LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurphsicles%2Fsecp256k1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmurphsicles%2Fsecp256k1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmurphsicles%2Fsecp256k1/lists"}