百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

curve25519-donna

> 编程语言
开源

快速椭圆曲线 Diffie-Hellman 原语的实现

347 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

快速椭圆曲线 Diffie-Hellman 原语的实现

curve25519-donna

Note: this code is from 2008. Since that time, many more, great implementations of curve25519 have been written, including several amd64 assembly versions by djb. You are probably better served now by NaCl or libsodium.

curve25519 is an elliptic curve, developed by Dan Bernstein, for fast Diffie-Hellman key agreement. DJB's original implementation was written in a language of his own devising called qhasm. The original qhasm source isn't available, only the x86 32-bit assembly output.

Since many x86 systems are now 64-bit, and portability is important, this project provides alternative implementations for other platforms.

Implementation Platform Author 32-bit speed 64-bit speed Constant Time
curve25519 x86 32-bit djb 265µs N/A yes
curve25519-donna-c64 64-bit C agl N/A 215µs yes
curve25591-donna Portable C agl 2179µs 610µs

(All tests run on a 2.33GHz Intel Core2)

Usage

The usage is exactly the same as djb's code (as described at http://cr.yp.to/ecdh.html) except that the function is called curve25519\_donna.

To generate a private key, generate 32 random bytes and:

mysecret[0] &= 248;
mysecret[31] &= 127;
mysecret[31] |= 64;

To generate the public key, just do:

static const uint8_t basepoint[32] = {9};
curve25519_donna(mypublic, mysecret, basepoint);

To generate a shared key do:

uint8_t shared_key[32];
curve25519_donna(shared_key, mysecret, theirpublic);

And hash the shared\_key with a cryptographic hash function before using.

For more information, see djb's page.

Building

If you run make, two .a archives will be built, similar to djb's curve25519 code. Alternatively, read on:

ESP8266

If you're interested in running curve25519 on an ESP8266, see this project.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言