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

Wrong result of multiplication of a MPCTensor and a public value #315

Open
xutongye opened this issue Nov 9, 2021 · 0 comments
Open

Wrong result of multiplication of a MPCTensor and a public value #315

xutongye opened this issue Nov 9, 2021 · 0 comments

Comments

@xutongye
Copy link
Member

xutongye commented Nov 9, 2021

Description

When multiply two large (relative to ring_size) values, the reconstructed result is wrong.

As I see it, when:

  • a wraparound (or say mod operation) happens in the computation process,
  • and the scale of the encoder is greater than 1,

then the result will be wrong.

How to Reproduce

Please run the following code, there are two examples showing this bug.

sy.logger.remove()
import torch
from sympc.session import Session
from sympc.config import Config
from sympc.session import SessionManager
from sympc.tensor import MPCTensor
parties = [sy.VirtualMachine(name=n).get_root_client() for n in ["alice", "bob"]]

# Example 1:
session = Session(parties=parties)
SessionManager.setup_mpc(session)
x_secret = torch.Tensor([1<<30])
x = x_secret.share(session=session)
z = x * 3
print(f"expect {x_secret*3}, but get {z.reconstruct()}")

# Example 2:
session = Session(parties=parties, ring_size=256, config=Config(encoder_base=10, encoder_precision=1))
SessionManager.setup_mpc(session)
x_secret = torch.Tensor([[0.1, -1], [-4, 4]])
x = x_secret.share(session=session)
z = x * 3
print(f"expect {x_secret*3}, but get {z.reconstruct()}")
@xutongye xutongye changed the title MPCTensor multiply public value get wrong result Wrong result of multiplication of a MPCTensor and a public value Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant