Skip to content

Commit

Permalink
xwing integration: add new functions to x25519 to facilitate xwing in…
Browse files Browse the repository at this point in the history
…tregration
  • Loading branch information
tfaoliveira-sb committed Apr 16, 2024
1 parent 3a10ee9 commit 7540ffa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
31 changes: 31 additions & 0 deletions src/crypto_scalarmult/curve25519/amd64/ref4/curve25519.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,22 @@ inline fn __curve25519_ref4(reg u64[4] _k _u) -> reg u64[4]
return r;
}

inline fn __curve25519_ref4_ptr(#spill_to_mmx reg u64 rp, reg u64 kp up)
{
reg u64[4] r k u;

() = #spill(rp);

k = __load4(kp);
u = __load4(up);
r = __curve25519_ref4(k, u);

() = #unspill(rp);

__store4(rp, r);
}


inline fn __curve25519_ref4_base(reg u64[4] _k) -> reg u64[4]
{
stack u8[32] k;
Expand All @@ -167,3 +183,18 @@ inline fn __curve25519_ref4_base(reg u64[4] _k) -> reg u64[4]
return r;
}

inline fn __curve25519_ref4_base_ptr(#spill_to_mmx reg u64 rp, reg u64 kp)
{
reg u64[4] r k;

() = #spill(rp);

k = __load4(kp);
r = __curve25519_ref4_base(k);

() = #unspill(rp);

__store4(rp, r);
}


19 changes: 2 additions & 17 deletions src/crypto_scalarmult/curve25519/amd64/ref4/scalarmult.jazz
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,10 @@ require "curve25519.jinc"
export fn jade_scalarmult_curve25519_amd64_ref4(#spill_to_mmx reg u64 qp np pp) -> reg u64
{
reg u64 r;
reg u64[4] q n p;

_ = #init_msf();

() = #spill(qp);
n = __load4(np);
p = __load4(pp);

q = __curve25519_ref4(n, p);

() = #unspill(qp);
__store4(qp, q);
__curve25519_ref4_ptr(qp, np, pp);

?{}, r = #set0();
return r;
Expand All @@ -24,17 +16,10 @@ export fn jade_scalarmult_curve25519_amd64_ref4(#spill_to_mmx reg u64 qp np pp)
export fn jade_scalarmult_curve25519_amd64_ref4_base(#spill_to_mmx reg u64 qp np) -> reg u64
{
reg u64 r;
reg u64[4] q n;

_ = #init_msf();

() = #spill(qp);
n = __load4(np);

q = __curve25519_ref4_base(n);

() = #unspill(qp);
__store4(qp, q);
__curve25519_ref4_base_ptr(qp, np);

?{}, r = #set0();
return r;
Expand Down

0 comments on commit 7540ffa

Please sign in to comment.