{"id":25420560,"url":"https://github.com/danielost/ecpoint-wrappers","last_synced_at":"2025-10-06T20:06:03.898Z","repository":{"id":207734078,"uuid":"719727345","full_name":"danielost/ecpoint-wrappers","owner":"danielost","description":"Convenient wrappers for operations on elliptic curves in Golang.","archived":false,"fork":false,"pushed_at":"2023-11-22T14:51:28.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T19:48:51.362Z","etag":null,"topics":["cryptography","ecc","elliptic-curves"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielost.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-11-16T19:19:40.000Z","updated_at":"2023-11-22T14:49:04.000Z","dependencies_parsed_at":"2025-02-16T19:48:18.250Z","dependency_job_id":"ff42be94-9f1a-4235-8bc3-1aadf3ee1406","html_url":"https://github.com/danielost/ecpoint-wrappers","commit_stats":null,"previous_names":["danielost/ecpoint-wrappers"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielost%2Fecpoint-wrappers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielost%2Fecpoint-wrappers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielost%2Fecpoint-wrappers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielost%2Fecpoint-wrappers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielost","download_url":"https://codeload.github.com/danielost/ecpoint-wrappers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253980063,"owners_count":21994043,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cryptography","ecc","elliptic-curves"],"created_at":"2025-02-16T19:48:09.711Z","updated_at":"2025-10-06T20:05:58.878Z","avatar_url":"https://github.com/danielost.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elliptic Curve points wrappers\n\nWrappers for operations on elliptic curves in Golang. Task №7 for the Cryptography for Developers course.\n\n## How to use\n\nExecute the following command first:\n```bash\ngo get github.com/danielost/ecpoint-wrappers\n```\nThen simply add the following import to your Go code:\n```bash\nimport (\n  // Importing the ecwrappers package\n  \"github.com/danielost/ecpoint-wrappers/pkg/ecwrapper\"\n)\n```\n### API description\n- `NewECPoint(x, y *big.Int) *ECPoint` - creates a new ECPoint with the given x and y coordinates.\n- `ECPointToString(point *ECPoint, base int) string` - converts an ECPoint to a string representation in the specified base.\n- `StringToECPoint(s string, base int) (*ECPoint, error)` - converts a string representation to an ECPoint in the specified base.\n- `NewECWrapper(curve elliptic.Curve) *ECWrapper` - creates a new ECWrapper with the specified elliptic curve.\n- `(ec *ECWrapper) GetBasePointG() *ECPoint` - returns the base point (generator) of the elliptic curve as an ECPoint.\n- `(ec *ECWrapper) IsOnCurve(point *ECPoint) bool` - checks if the given ECPoint lies on the elliptic curve.\n- `(ec *ECWrapper) Add(point1, point2 *ECPoint) *ECPoint` - performs point addition on the elliptic curve and returns the result as an ECPoint.\n- `(ec *ECWrapper) Double(point *ECPoint) *ECPoint` - performs point doubling on the elliptic curve and returns the result as an ECPoint.\n- `(ec *ECWrapper) ScalarMult(k *big.Int, point *ECPoint) *ECPoint` - performs scalar multiplication of an ECPoint with a scalar value and returns the result as an ECPoint.\n\n## Examples\nAs an example, we can check `k*(d*G) = d*(k*G)` equality. Any curve can be used for this, but for the demonstration `elliptic.P256()` is used.\n\nFull block of code checking the above equality:\n```go\npackage main\n\nimport (\n\t\"crypto/elliptic\"\n\t\"crypto/rand\"\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"math/big\"\n\n\t\"github.com/danielost/ecpoint-wrappers/pkg/ecwrapper\"\n)\n\n// Is k*(d*G) = d*(k*G)?\nfunc main() {\n\t// Define and set the elliptic curve to P256\n\tcurve := elliptic.P256()\n\n\t// Dependency injection: Create an elliptic curve wrapper object using the defined curve\n\tcurveWrapper := ecwrapper.NewECWrapper(curve)\n\n\t// Retrieve the base point G of the curve\n\tG := curveWrapper.GetBasePointG()\n\tk, d := \u0026big.Int{}, \u0026big.Int{}\n\n\t// Generate random scalar values k and d\n\tk, _ = k.SetString(randToken(32), 16)\n\td, _ = d.SetString(randToken(32), 16)\n\n\t// Calculate H1 = d * G\n\tH1 := curveWrapper.ScalarMult(d, G)\n\n\t// Calculate H2 = k * H1\n\tH2 := curveWrapper.ScalarMult(k, H1)\n\n\t// Calculate H3 = k * G\n\tH3 := curveWrapper.ScalarMult(k, G)\n\n\t// Calculate H4 = d * H3\n\tH4 := curveWrapper.ScalarMult(d, H3)\n\n\tH2.Print(16)\n\tH4.Print(16)\n\n\t// Check if H2 and H4 are equal (commutative property of scalar multiplication)\n\tfmt.Println(H2.IsEqual(H4))\n}\n\n// Generates a random hexadecimal token of the specified length\nfunc randToken(n int) string {\n\tbytes := make([]byte, n)\n\trand.Read(bytes)\n\treturn hex.EncodeToString(bytes)\n}\n\n```\n\n## Testing\nTo run the tests, clone the repository and execute the following command:\n```bash\ngo test ./...\n```\nor (for the detailed view):\n```bash\ngo test -v ./...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielost%2Fecpoint-wrappers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielost%2Fecpoint-wrappers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielost%2Fecpoint-wrappers/lists"}