Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x25519 sct #115

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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