Skip to content
Draft
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
3 changes: 2 additions & 1 deletion .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ env:

jobs:
lint:
runs-on: ubuntu-latest
# Keep older supported Python versions available on the runner.
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [ 3.9, "3.10", 3.11, 3.12 ]
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ env:
jobs:
docs:
name: Build and deploy documentation
runs-on: ubuntu-latest
# Keep older supported Python versions available on the runner.
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
Expand Down
74 changes: 49 additions & 25 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@ on:
push:
branches:
- 'build-wheel'
pull_request:
paths:
- 'setup.cfg'
- '.github/workflows/wheels.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
build_linux_wheels:
name: build linux wheels
runs-on: ubuntu-latest
env:
PY_VERS: cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: set up container
run: |
docker create --name linux_build -i -v /:/host quay.io/pypa/manylinux2014_x86_64:latest /bin/bash
docker create --name linux_build -i quay.io/pypa/manylinux2014_x86_64:latest /bin/bash
docker cp . linux_build:/cryptomite/
- name: run build
run: |
Expand All @@ -25,38 +36,42 @@ jobs:
with:
name: linux_wheels
path: wheelhouse/
if-no-files-found: error
build_macos_wheels:
name: build macos wheels
runs-on: macos-13
runs-on: macos-15-intel
env:
MACOSX_DEPLOYMENT_TARGET: '13.0'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: set up python 3.9
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.9'
- name: build wheel (3.9)
run: .github/workflows/macosbuildwheel
- name: set up python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.10'
- name: build wheel (3.10)
run: .github/workflows/macosbuildwheel
- name: set up python 3.11
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: build wheel (3.11)
run: .github/workflows/macosbuildwheel
- name: set up python 3.12
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: build wheel (3.12)
run: .github/workflows/macosbuildwheel
- uses: actions/checkout@v2
- name: set up python '3.13'
uses: actions/setup-python@v2
- name: set up python 3.13
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: build wheel (3.13)
Expand All @@ -65,31 +80,36 @@ jobs:
with:
name: macos_wheels
path: wheelhouse/
if-no-files-found: error
build_macos_m1_wheels:
name: build macos M1 wheels
runs-on: macos-latest-xlarge
runs-on: macos-15
env:
MACOSX_DEPLOYMENT_TARGET: '14.0'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: set up python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.10'
- name: build wheel (3.10)
run: .github/workflows/macosbuildwheel
- name: set up python 3.11
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: build wheel (3.11)
run: .github/workflows/macosbuildwheel
- name: set up python 3.12
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: build wheel (3.12)
run: .github/workflows/macosbuildwheel
- name: set up python 3.13
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: build wheel (3.13)
Expand All @@ -98,53 +118,56 @@ jobs:
with:
name: macos_m1_wheels
path: wheelhouse/
if-no-files-found: error
build_windows_wheels:
name: build windows wheels
runs-on: windows-2019
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: set up python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.8'
- name: build wheel (3.8)
run: |
python -m pip install -U pip wheel scikit-build
python setup.py bdist_wheel -d "${{ github.workspace }}/wheelhouse"
- name: set up python 3.9
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.9'
- name: build wheel (3.9)
run: |
python -m pip install -U pip wheel scikit-build
python setup.py bdist_wheel -d "${{ github.workspace }}/wheelhouse"
- name: set up python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.10'
- name: build wheel (3.10)
run: |
python -m pip install -U pip wheel scikit-build
python setup.py bdist_wheel -d "${{ github.workspace }}/wheelhouse"
- name: set up python 3.11
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: build wheel (3.11)
run: |
python -m pip install -U pip wheel scikit-build
python setup.py bdist_wheel -d "${{ github.workspace }}/wheelhouse"
- name: set up python 3.12
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: build wheel (3.12)
run: |
python -m pip install -U pip wheel scikit-build
python setup.py bdist_wheel -d "${{ github.workspace }}/wheelhouse"
- name: set up python 3.13
uses: actions/setup-python@v2
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: build wheel (3.13)
Expand All @@ -155,3 +178,4 @@ jobs:
with:
name: windows_wheels
path: wheelhouse/
if-no-files-found: error
2 changes: 1 addition & 1 deletion cryptomite/raz.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def extract(self, input1: BitsT, input2: BitsT) -> BitsT:
assert 0 < len(input2) <= self.n

x1, x2 = input1[0:self.n], input1[self.n:]
y = input2 + [0] * (len(input2) - self.n)
y = input2 + [0] * (self.n - len(input2))

pad_amount = self.pad_amount
x1 = x1 + [0]*pad_amount
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = cryptomite
description = An awesome extractor library
long_description = file: README.md
long_description_content_type = text/markdown
version = 0.3.0
version = 0.3.1
author = Cambridge Quantum
author_email = qcrypto@cambridgequantum.com
license_files = file: LICENSE
Expand Down
25 changes: 25 additions & 0 deletions test/test_raz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from cryptomite.raz import Raz

import pytest


@pytest.mark.parametrize('n', [3, 7, 15])
@pytest.mark.parametrize('input_length', ['one', 'short', 'full'])
def test_raz_zero_extension(n, input_length, monkeypatch):
extractor = Raz(2 * n, n)
length = {'one': 1, 'short': n - 1, 'full': n}[input_length]
input1 = [i % 2 for i in range(2 * n)]
input2 = [(i + 1) % 2 for i in range(length)]
original_input2 = input2.copy()
multiply = extractor.gf_mul

def checked_multiply(x, y):
# Reject undersized buffers before the native NTT reads past them.
assert len(x) == len(y) == 1 << extractor.logp
return multiply(x, y)

monkeypatch.setattr(extractor, 'gf_mul', checked_multiply)
expected = extractor.extract(input1, input2 + [0] * (n - length))

assert extractor.extract(input1, input2) == expected
assert input2 == original_input2
Loading