types.rs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /// Types supported by the VM
  2. #[derive(Copy, Clone, PartialEq, Debug)]
  3. #[repr(u8)]
  4. pub enum Type {
  5. /// Elliptic curve point
  6. EcPoint = 0x00,
  7. /// Elliptic curve fixed point (a constant)
  8. EcFixedPoint = 0x01,
  9. /// Base field element
  10. Base = 0x10,
  11. /// Array of Base field elements
  12. BaseArray = 0x11,
  13. /// Scalar field element
  14. Scalar = 0x12,
  15. /// Array of Scalar field elements
  16. ScalarArray = 0x13,
  17. /// A Merkle path
  18. MerklePath = 0x20,
  19. /// Unsigned 32-bit integer
  20. Uint32 = 0x30,
  21. /// Intermediate type, should never appear in the result
  22. Dummy = 0xff,
  23. }
  24. impl Type {
  25. pub fn from_repr(b: u8) -> Self {
  26. match b {
  27. 0x00 => Self::EcPoint,
  28. 0x01 => Self::EcFixedPoint,
  29. 0x10 => Self::Base,
  30. 0x11 => Self::BaseArray,
  31. 0x12 => Self::Scalar,
  32. 0x13 => Self::ScalarArray,
  33. 0x20 => Self::MerklePath,
  34. 0x30 => Self::Uint32,
  35. _ => unimplemented!(),
  36. }
  37. }
  38. }