-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
118 lines (106 loc) · 3.69 KB
/
Copy pathflake.nix
File metadata and controls
118 lines (106 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{
description = "Hardware Private Cubic Circuits";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
prolead.url = "github:ChairImpSec/PROLEAD";
yosys_slang = {
url = "https://github.com/povik/yosys-slang";
rev = "8c5b73ed2f5d7d105d2fec8ab23cfdd9c066119a";
flake = false;
type = "git";
submodules = true;
};
};
outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
perSystem =
{ pkgs, inputs', ... }:
let
prolead = inputs'.prolead.packages.default;
yosys-slang = pkgs.stdenv.mkDerivation (finalAttrs: {
pname = "yosys-slang";
version = "0.0.1";
src = inputs.yosys_slang;
nativeBuildInputs = with pkgs; [ cmake ];
buildInputs = with pkgs; [ yosys ];
installPhase = ''
mkdir -p $out/lib
cp slang.so $out/lib/slang.so
'';
});
yosys-with-slang = pkgs.writeShellApplication {
name = "yosys";
text = ''
exec ${pkgs.yosys}/bin/yosys -m ${yosys-slang}/lib/slang.so "$@"
'';
};
toolchain = with pkgs; [
gnumake
haskellPackages.sv2v
yosys-with-slang
iverilog
pypy3
git
];
in
{
packages = {
syn = pkgs.writeShellApplication {
name = "syn";
runtimeInputs = toolchain;
text = ''
for a in 1 2 4; do
for b in 0 1; do
for c in 2 3 4; do
for d in 1 4; do
make NUM_A_MULTS=$a MAKE_BC_MULT=$b NUM_SHARES=$c BIT_WIDTH=$d syn_masked_hpcc_mul
done
done
done
done
for i in 2 3 4; do make NUM_SHARES=$i syn_masked_2stage_aes_sbox; done
'';
};
test = pkgs.writeShellApplication {
name = "test";
runtimeInputs = toolchain;
text = ''
for i in 2 3 4; do for j in 1 4; do make NUM_SHARES=$i BIT_WIDTH=$j test_masked_hpcc_mul; done; done
for i in 2 3 4; do make NUM_SHARES=$i test_masked_2stage_aes_sbox; done
'';
};
verif = pkgs.writeShellApplication {
name = "verif";
runtimeInputs = toolchain;
text = ''
for i in 2 3 4; do for j in 1 2; do make NUM_SHARES=$i BIT_WIDTH=$j verif_masked_hpcc_mul; done; done
'';
};
prolead-verif = pkgs.writeShellApplication {
name = "prolead-verif";
runtimeInputs = toolchain ++ [ prolead ];
text = ''
./prolead/run.sh masked_hpcc_mul_prolead_bw1_d1 masked_hpcc_mul_prolead
./prolead/run.sh masked_hpcc_mul_prolead_bw1_d2 masked_hpcc_mul_prolead
./prolead/run.sh masked_hpcc_mul_bw1_d3 masked_hpcc_mul
./prolead/run.sh masked_2stage_aes_sbox_d1 masked_2stage_aes_sbox
./prolead/run.sh masked_2stage_aes_sbox_d2 masked_2stage_aes_sbox
'';
};
inherit yosys-slang yosys-with-slang;
};
devShells.default = pkgs.mkShell {
packages = toolchain ++ [ prolead ];
};
formatter = pkgs.nixfmt-rfc-style;
};
};
}