const X25519_KEY_SIZE
XuAPI
pub const X25519_KEY_SIZE = 32用途
常量 X25519_KEY_SIZE,定义了相关的协议或算法配置参数。
#crypto/ecdh标准库包 `#crypto/ecdh`。
const X25519_KEY_SIZEpub const X25519_KEY_SIZE = 32常量 X25519_KEY_SIZE,定义了相关的协议或算法配置参数。
struct Curvepub struct Curve {
pub name string
}承载 name 等属性的结构体。
name stringx25519pub fn x25519() Curve执行 x25519 处理。
无需传入参数。
Curve — 该类型的值
struct PublicKeypub struct PublicKey {
pub curve Curve
pub raw string
}承载 curve、raw 等属性的结构体。
curve Curveraw string(&PublicKey) bytespub fn (k &PublicKey) bytes() string&PublicKey 上的操作:返回已缓冲的字节串。
k &PublicKeyPublicKey 实例;以只读借用传入,调用方仍持有实例。string — 结果字符串
(&PublicKey) equalpub fn (k &PublicKey) equal(other &PublicKey) bool&PublicKey 上的操作:判断两值是否相等。
k &PublicKeyPublicKey 实例;以只读借用传入,调用方仍持有实例。other &PublicKeybool — 是否成立
struct PrivateKeypub struct PrivateKey {
pub curve Curve
pub raw string
pub pub_key PublicKey
}承载 curve、raw、pub_key 等属性的结构体。
curve Curveraw stringpub_key PublicKey(&PrivateKey) bytespub fn (k &PrivateKey) bytes() string&PrivateKey 上的操作:返回已缓冲的字节串。
k &PrivateKeyPrivateKey 实例;以只读借用传入,调用方仍持有实例。string — 结果字符串
(&PrivateKey) public_keypub fn (k &PrivateKey) public_key() PublicKey&PrivateKey 上的操作:公钥键。
k &PrivateKeyPrivateKey 实例;以只读借用传入,调用方仍持有实例。PublicKey — 该类型的值
(&PrivateKey) equalpub fn (k &PrivateKey) equal(other &PrivateKey) bool&PrivateKey 上的操作:判断两值是否相等。
k &PrivateKeyPrivateKey 实例;以只读借用传入,调用方仍持有实例。other &PrivateKeybool — 是否成立
base_pointpub fn base_point() string执行 base point 操作。
无需传入参数。
string — 结果字符串
scalar_multpub fn scalar_mult(scalar &string, point &string) string执行 scalar mult 操作。失败时抛出错误,调用方需处理或继续传播。
scalar &stringpoint &stringstring — 结果字符串
new_public_keypub fn new_public_key(c Curve, key &string) PublicKey构造 public key。失败时抛出错误,调用方需处理或继续传播。
c Curvekey &stringPublicKey — 该类型的值
new_private_keypub fn new_private_key(c Curve, key &string) PrivateKey构造 private key。失败时抛出错误,调用方需处理或继续传播。
c Curvekey &stringPrivateKey — 该类型的值
generate_keypub fn generate_key(c Curve) PrivateKey生成键。失败时抛出错误,调用方需处理或继续传播。
c CurvePrivateKey — 该类型的值
(&PrivateKey) ecdhpub fn (k &PrivateKey) ecdh(remote &PublicKey) string&PrivateKey 上的操作:基于椭圆曲线私钥与对端公钥计算共享密钥(ECDH 密钥协商)。失败时抛出错误,调用方需处理或继续传播。
k &PrivateKeyPrivateKey 实例;以只读借用传入,调用方仍持有实例。remote &PublicKeystring — 结果字符串