Skip to content

Commit

Permalink
Merge pull request #115 from formosa-crypto/feature/x25519_sct
Browse files Browse the repository at this point in the history
x25519 sct
  • Loading branch information
tfaoliveira authored Apr 16, 2024
2 parents 040279b + 95b6442 commit fdfd52a
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 34 deletions.
8 changes: 4 additions & 4 deletions src/crypto_scalarmult/curve25519/amd64/mulx/curve25519.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ inline fn __montgomery_ladder4(
{
stack u64[4] us x2 x3 z3;
reg u64[4] z2r;
stack u64 ctrs swapped;
reg u64 ctr;
stack u64 swapped;
#spill_to_mmx reg u64 ctr;

(x2,z2r,x3,z3) = __init_points4(u);
us = #copy(u);
Expand All @@ -109,12 +109,12 @@ inline fn __montgomery_ladder4(
while
{
ctr -= 1;
ctrs = ctr;
() = #spill(ctr);

(x2, z2r, x3, z3, swapped) =
__montgomery_ladder_step4(k, us, x2, z2r, x3, z3, swapped, ctr);

ctr = ctrs;
() = #unspill(ctr);
} (ctr > 0)

return x2, z2r;
Expand Down
18 changes: 10 additions & 8 deletions src/crypto_scalarmult/curve25519/amd64/mulx/scalarmult.jazz
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
from Jade require "crypto_scalarmult/curve25519/amd64/common/load_store4.jinc"
require "curve25519.jinc"

export fn jade_scalarmult_curve25519_amd64_mulx(reg u64 qp np pp) -> reg u64
export fn jade_scalarmult_curve25519_amd64_mulx(#spill_to_mmx reg u64 qp np pp) -> reg u64
{
reg u64 r;
stack u64 qps;
reg u64[4] q n p;

qps = qp;
_ = #init_msf();

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

q = __curve25519_mulx(n, p);

qp = qps;
() = #unspill(qp);
__store4(qp, q);

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

export fn jade_scalarmult_curve25519_amd64_mulx_base(reg u64 qp np) -> reg u64
export fn jade_scalarmult_curve25519_amd64_mulx_base(#spill_to_mmx reg u64 qp np) -> reg u64
{
reg u64 r;
stack u64 qps;
reg u64[4] q n;

qps = qp;
_ = #init_msf();

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

q = __curve25519_mulx_base(n);

qp = qps;
() = #unspill(qp);
__store4(qp, q);

?{}, r = #set0();
Expand Down
8 changes: 4 additions & 4 deletions src/crypto_scalarmult/curve25519/amd64/ref4/curve25519.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ inline fn __montgomery_ladder4(
{
stack u64[4] us x2 x3 z3;
reg u64[4] z2r;
stack u64 ctrs swapped;
reg u64 ctr;
stack u64 swapped;
#spill_to_mmx reg u64 ctr;

(x2,z2r,x3,z3) = __init_points4(u);
us = #copy(u);
Expand All @@ -108,12 +108,12 @@ inline fn __montgomery_ladder4(
while
{
ctr -= 1;
ctrs = ctr;
() = #spill(ctr);

(x2, z2r, x3, z3, swapped) =
__montgomery_ladder_step4(k, us, x2, z2r, x3, z3, swapped, ctr);

ctr = ctrs;
() = #unspill(ctr);
} (ctr > 0)

return x2, z2r;
Expand Down
18 changes: 10 additions & 8 deletions src/crypto_scalarmult/curve25519/amd64/ref4/scalarmult.jazz
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
from Jade require "crypto_scalarmult/curve25519/amd64/common/load_store4.jinc"
require "curve25519.jinc"

export fn jade_scalarmult_curve25519_amd64_ref4(reg u64 qp np pp) -> reg u64
export fn jade_scalarmult_curve25519_amd64_ref4(#spill_to_mmx reg u64 qp np pp) -> reg u64
{
reg u64 r;
stack u64 qps;
reg u64[4] q n p;

qps = qp;
_ = #init_msf();

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

q = __curve25519_ref4(n, p);

qp = qps;
() = #unspill(qp);
__store4(qp, q);

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

export fn jade_scalarmult_curve25519_amd64_ref4_base(reg u64 qp np) -> reg u64
export fn jade_scalarmult_curve25519_amd64_ref4_base(#spill_to_mmx reg u64 qp np) -> reg u64
{
reg u64 r;
stack u64 qps;
reg u64[4] q n;

qps = qp;
_ = #init_msf();

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

q = __curve25519_ref4_base(n);

qp = qps;
() = #unspill(qp);
__store4(qp, q);

?{}, r = #set0();
Expand Down
8 changes: 4 additions & 4 deletions src/crypto_scalarmult/curve25519/amd64/ref5/curve25519.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ inline fn __montgomery_ladder5(
{
stack u64[5] us x2 x3 z3;
reg u64[5] z2r;
stack u64 ctrs swapped;
reg u64 ctr;
stack u64 swapped;
#spill_to_mmx reg u64 ctr;

(x2,z2r,x3,z3) = __init_points5(u);
us = #copy(u);
Expand All @@ -106,12 +106,12 @@ inline fn __montgomery_ladder5(
while
{
ctr -= 1;
ctrs = ctr;
() = #spill(ctr);

(x2, z2r, x3, z3, swapped) =
__montgomery_ladder_step5(k, us, x2, z2r, x3, z3, swapped, ctr);

ctr = ctrs;
() = #unspill(ctr);
} (ctr > 0)

return x2, z2r;
Expand Down
16 changes: 10 additions & 6 deletions src/crypto_scalarmult/curve25519/amd64/ref5/scalarmult.jazz
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
from Jade require "crypto_scalarmult/curve25519/amd64/common/load_store4.jinc"
require "curve25519.jinc"

export fn jade_scalarmult_curve25519_amd64_ref5(reg u64 qp np pp) -> reg u64
export fn jade_scalarmult_curve25519_amd64_ref5(#spill_to_mmx reg u64 qp np pp) -> reg u64
{
reg u64 r;
stack u64 qps;
reg u64[4] q n p;

qps = qp;
_ = #init_msf();

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

q = __curve25519_ref5(n, p);

qp = qps;
() = #unspill(qp);
__store4(qp, q);

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

export fn jade_scalarmult_curve25519_amd64_ref5_base(reg u64 qp np) -> reg u64
export fn jade_scalarmult_curve25519_amd64_ref5_base(#spill_to_mmx reg u64 qp np) -> reg u64
{
reg u64 r;
stack u64 qps;
reg u64[4] q n;

qps = qp;
_ = #init_msf();

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

q = __curve25519_ref5_base(n);

qp = qps;
() = #unspill(qp);
__store4(qp, q);

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

0 comments on commit fdfd52a

Please sign in to comment.