- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1
Tips
        Ushitora Anqou edited this page Sep 12, 2021 
        ·
        3 revisions
      
    jqの-cオプションを使って最小化できる。また、Iyokanが使用しないフィールドを適当にjqで削ると若干小さくなる。
例えば次の通り。
$ cat fat.json | jq -c 'del(..|.port_directions?) | del(..|.parameters?) | del(..|.attributes?) | del(..|.hide_name?)' > slim.jsoniyokanを実行するとビルド設定が表示される。全く引数を与えない場合でも表示される。
$ build/bin/iyokan
[2021-09-12 09:13:15.599] [iyokan] [info] Build config
[2021-09-12 09:13:15.599] [iyokan] [info] 	Type: Release
[2021-09-12 09:13:15.599] [iyokan] [info] 	Git revision: f167d43
[2021-09-12 09:13:15.599] [iyokan] [info] 	TFHE security parameter: CGGI16 (80bit)
[2021-09-12 09:13:15.599] [iyokan] [info] 	GPU support: enabled
A subcommand is required
Run with --help for more information.仕様TOMLファイルと入力TOMLファイルを指定すると、パケット生成・暗号化・実行・復号・出力TOMLファイル生成をやってくれるようなシェルスクリプトを書いておくと便利である。 例えば次のように書ける。
#!/bin/sh -xue
if [ $# -ne 4 -a $# -ne 5 ]; then
    echo "Usage: $0 BUILD-BIN-DIR TYPE BLUEPRINT-FILE INPUT-FILE [NCYCLES]" >&2
    exit 1
fi
IYOKAN_BIN=$1
TYPE=$2
BLUEPRINT_FILE=$3
INPUT_FILE=$4
NCYCLES=${5:-"-1"}
OPTIONS="--verbose --show-combinational-progress"
IYOKAN="$IYOKAN_BIN/iyokan"
IYOKAN_PACKET="$IYOKAN_BIN/iyokan-packet"
case $TYPE in
    plain )
        ;;
    tfhe )
        OPTIONS="$OPTIONS"
        ;;
    cufhe )
        OPTIONS="$OPTIONS --enable-gpu --num-gpu 1"
        ;;
esac
$IYOKAN_PACKET toml2packet --in $INPUT_FILE --out _test_plain_req
case $TYPE in
    plain )
        $IYOKAN plain --blueprint $BLUEPRINT_FILE -i _test_plain_req -o _test_plain_res -c $NCYCLES $OPTIONS
        $IYOKAN_PACKET packet2toml --in _test_plain_res
        ;;
    tfhe | cufhe )
        [ -f _test_sk ] || $IYOKAN_PACKET genkey --type tfhepp --out _test_sk
        [ -f _test_bk ] || $IYOKAN_PACKET genbkey --in _test_sk --out _test_bk
        $IYOKAN_PACKET enc --key _test_sk --in _test_plain_req --out _test_req
        $IYOKAN tfhe --blueprint $BLUEPRINT_FILE -c $NCYCLES --bkey _test_bk -i _test_req -o _test_res $OPTIONS
        $IYOKAN_PACKET dec --key _test_sk --in _test_res --out _test_plain_res
        $IYOKAN_PACKET packet2toml --in _test_plain_res
        ;;
esac