ronantakizawa/codereview-bench huggingface dataset:
Repository: mrsked/mrsk
File: lib/kamal/commands/base.rb (Ruby)

Code before:
module Kamal::Commands
  class Base
    delegate :sensitive, :argumentize, to: Kamal::Utils

    DOCKER_HEALTH_STATUS_FORMAT = "'{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}'"

    attr_accessor :config

    def initialize(config)
      @config = config
    end

    def run_over_ssh(*command, host:)
      "ssh#{ssh_proxy_args} -t #{config.ssh.user}@#{host} -p #{config.ssh.port} '#{command.join(" ").gsub("'", "'\\\\''")}'".squish
    end

    def container_id_for(container_name:, only_running: false)
      docker :container, :ls, *("--all" unless only_running), "--filter", "name=^#{container_name}$", "--quiet"
    end

    def make_directory_for(remote_file)
      make_directory Pathname.new(remote_file).dirname.to_s
    end

    def make_directory(path)
      [ :mkdir, "-p", path ]
    end

    def remove_directory(path)
      [ :rm, "-r", path ]
    end

    def remove_file(path)
      [ :rm, path ]
    end

    private
      def combine(*commands, by: "&&")
        commands

Review comment (suggestion):
```suggestion
      "ssh #{ssh_proxy_args} -t #{config.ssh.user}@#{host} -p #{config.ssh.port} '#{command.join(" ").gsub("'", "'\\\\''")}'".squish
```

Code after:
module Kamal::Commands
  class Base
    delegate :sensitive, :argumentize, to: Kamal::Utils

    DOCKER_HEALTH_STATUS_FORMAT = "'{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}'"

    attr_accessor :config

    def initialize(config)
      @config = config
    end

    def run_over_ssh(*command, host:)
      "ssh#{ssh_proxy_args} -t #{config.ssh.user}@#{host} -p #{config.ssh.port} '#{command.join(" ").gsub("'", "'\\\\''")}'"
    end

    def container_id_for(container_name:, only_running: false)
      docker :container, :ls, *("--all" unless only_running), "--filter", "name=^#{container_name}$", "--quiet"
    end

    def make_directory_for(remote_file)
      make_directory Pathname.new(remote_file).dirname.to_s
    end

    def make_directory(path)
      [ :mkdir, "-p", path ]
    end

    def remove_directory(path)
      [ :rm, "-r", path ]
    end

    def remove_file(path)
      [ :rm, path ]
    end

    private
      def combine(*commands, by: "&&")
        commands
Repository: mrsked/mrsk
File: lib/kamal/commands/base.rb (Ruby)

Code before:
module Kamal::Commands
  class Base
    delegate :sensitive, :argumentize, to: Kamal::Utils

    DOCKER_HEALTH_STATUS_FORMAT = "'{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}'"

    attr_accessor :config

    def initialize(config)
      @config = config
    end

    def run_over_ssh(*command, host:)
      "ssh#{ssh_proxy_args} -t #{config.ssh.user}@#{host} -p #{config.ssh.port} '#{command.join(" ").gsub("'", "'\\\\''")}'".squish
    end

    def container_id_for(container_name:, only_running: false)
      docker :container, :ls, *("--all" unless only_running), "--filter", "name=^#{container_name}$", "--quiet"
    end

    def make_directory_for(remote_file)
      make_directory Pathname.new(remote_file).dirname.to_s
    end

    def make_directory(path)
      [ :mkdir, "-p", path ]
    end

    def remove_directory(path)
      [ :rm, "-r", path ]
    end

    def remove_file(path)
      [ :rm, path ]
    end

    private
      def combine(*commands, by: "&&")
        commands

Review comment (suggestion):
```suggestion
      "ssh#{ssh_proxy_args} -t #{config.ssh.user}@#{host} -p #{config.ssh.port} '#{command.join(" ").gsub("'", "'\\\\''")}'"
```

Code after:
module Kamal::Commands
  class Base
    delegate :sensitive, :argumentize, to: Kamal::Utils

    DOCKER_HEALTH_STATUS_FORMAT = "'{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}'"

    attr_accessor :config

    def initialize(config)
      @config = config
    end

    def run_over_ssh(*command, host:)
      "ssh#{ssh_proxy_args} -t #{config.ssh.user}@#{host} -p #{config.ssh.port} '#{command.join(" ").gsub("'", "'\\\\''")}'"
    end

    def container_id_for(container_name:, only_running: false)
      docker :container, :ls, *("--all" unless only_running), "--filter", "name=^#{container_name}$", "--quiet"
    end

    def make_directory_for(remote_file)
      make_directory Pathname.new(remote_file).dirname.to_s
    end

    def make_directory(path)
      [ :mkdir, "-p", path ]
    end

    def remove_directory(path)
      [ :rm, "-r", path ]
    end

    def remove_file(path)
      [ :rm, path ]
    end

    private
      def combine(*commands, by: "&&")
        commands
Repository: mrsked/mrsk
File: lib/kamal/commands/docker.rb (Ruby)

Code before:
class Kamal::Commands::Docker < Kamal::Commands::Base
  # Install Docker using the https://github.com/docker/docker-install convenience script.
  def install
    pipe get_docker, :sh
  end

  # Checks the Docker client version. Fails if Docker is not installed.
  def installed?
    docker "-v"
  end

  # Checks the Docker server version. Fails if Docker is not running.
  def running?
    docker :version
  end

  # Do we have superuser access to install Docker and start system services?
  def superuser?
    [ '[ "${EUID:-$(id -u)}" -eq 0 ] || command -v sudo >/dev/null || command -v su >/dev/null' ]
  end

  # If we're not root and not already in the docker group
  # add us to the docker group and terminate all our current sessions
  def add_group
    [ '[ "${EUID:-$(id -u)}" -eq 0 ] || id -nG "${USER:-$(id -un)}" | grep -qw docker || { sudo usermod -aG docker "${USER:-$(id -un)}" && kill -HUP ${PPID:-ps -o ppid= -p $$}; }' ]
  end

  def create_network
    docker :network, :create, :kamal
  end

  private
    def get_docker
      shell \
        any \
          [ :curl, "-fsSL", "https://get.docker.com" ],
          [ :wget, "-O -", "https://get.docker.com" ],
          [ :echo, "\"exit 1\"" ]
    end
end


Review comment (bug):
@NeilW - could you try the newgrp command that @kdiogenes suggested?

Also I think we should have `sudo -n` to ensure that it fails rather than prompt for a password if one is needed.

Code after:
class Kamal::Commands::Docker < Kamal::Commands::Base
  # Install Docker using the https://github.com/docker/docker-install convenience script.
  def install
    pipe get_docker, :sh
  end

  # Checks the Docker client version. Fails if Docker is not installed.
  def installed?
    docker "-v"
  end

  # Checks the Docker server version. Fails if Docker is not running.
  def running?
    docker :version
  end

  # Do we have superuser access to install Docker and start system services?
  def superuser?
    [ '[ "${EUID:-$(id -u)}" -eq 0 ] || sudo -nl usermod >/dev/null' ]
  end

  # If we're not root and not already in the docker group
  # add us to the docker group and terminate all our current sessions
  def add_group
    [ '[ "${EUID:-$(id -u)}" -eq 0 ] || id -nG "${USER:-$(id -un)}" | grep -qw docker || { sudo -n usermod -aG docker "${USER:-$(id -un)}" && kill -HUP ${PPID:-ps -o ppid= -p $$}; }' ]
  end

  def create_network
    docker :network, :create, :kamal
  end

  private
    def get_docker
      shell \
        any \
          [ :curl, "-fsSL", "https://get.docker.com" ],
          [ :wget, "-O -", "https://get.docker.com" ],
          [ :echo, "\"exit 1\"" ]
    end
end
Repository: mrsked/mrsk
File: lib/kamal/secrets/adapters/doppler.rb (Ruby)

Code before:
class Kamal::Secrets::Adapters::Doppler < Kamal::Secrets::Adapters::Base
  private
    def login(account)
      unless loggedin?(account)
        `doppler login -y`
        raise RuntimeError, "Failed to login to Doppler" unless $?.success?
      end
    end

    def loggedin?(account)
      `doppler me --json 2> /dev/null`
      $?.success?
    end

    def fetch_secrets(secrets, account:, session:)
      project, config = account.split("/")

      raise RuntimeError, "Missing project or config from --acount=project/config option" unless project && config
      raise RuntimeError, "Using --from option or FOLDER/SECRET is not supported by Doppler" if secrets.any?(/\//)

      items = `doppler secrets get #{secrets.map(&:shellescape).join(" ")} --json -p #{project} -c #{config}`
      raise RuntimeError, "Could not read #{secrets} from Doppler" unless $?.success?

      items = JSON.parse(items)

      items.transform_values { |value| value["computed"] }
    end
end


Review comment (security):
We should shell escape `project` and `config` here as well as we are injecting user input. Admittedly probably a friendly user, but best to be on the safe side.

Code after:
class Kamal::Secrets::Adapters::Doppler < Kamal::Secrets::Adapters::Base
  def requires_account?
    false
  end

  private
    def login(*)
      unless loggedin?
        `doppler login -y`
        raise RuntimeError, "Failed to login to Doppler" unless $?.success?
      end
    end

    def loggedin?
      `doppler me --json 2> /dev/null`
      $?.success?
    end

    def fetch_secrets(secrets, **)
      project_and_config_flags = ""
      unless service_token_set?
        project, config, _ = secrets.first.split("/")

        unless project && config
          raise RuntimeError, "Missing project or config from '--from=project/config' option"
        end

        project_and_config_flags = "-p #{project.shellescape} -c #{config.shellescape}"
      end

      secret_names = secrets.collect { |s| s.split("/").last }

      items = `doppler secrets get #{secret_names.map(&:shellescape).join(" ")} --json #{project_and_config_flags}`
      raise RuntimeError, "Could not read #{secrets} from Doppler" unless $?.success?

      items = JSON.parse(items)

      items.transform_values { |value| value["computed"] }
    end

    def service_token_set?
      ENV["DOPPLER_TOKEN"] && ENV["DOPPLER_TOKEN"][0, 5] == "dp.st"
    end

    def check_dependencies!
      raise RuntimeError, "Doppler CLI is not installed" unless cli_installed?
Repository: mrsked/mrsk
File: test/env_file_test.rb (Ruby)

Code before:
require "test_helper"

class EnvFileTest < ActiveSupport::TestCase
  test "to_s" do
    env = {
      "foo" => "bar",
      "baz" => "haz"
    }

    assert_equal "foo=bar\nbaz=haz\n", \
      Kamal::EnvFile.new(env).to_s
  end

  test "to_s won't escape '#'" do
    env = {
      "foo" => "\#$foo",
      "bar" => "\#{bar}"
    }

    assert_equal "foo=\#$foo\nbar=\#{bar}\n", \
      Kamal::EnvFile.new(env).to_s
  end

  test "to_str won't escape chinese characters" do
    env = {
      "foo" => '你好 means hello, "欢迎" means welcome, that\'s simple! 😃 {smile}'
    }

    assert_equal "foo=你好 means hello, \"欢迎\" means welcome, that's simple! 😃 {smile}\n",
      Kamal::EnvFile.new(env).to_s
  end

  test "to_s won't escape japanese characters" do
    env = {
      "foo" => 'こんにちは means hello, "ようこそ" means welcome, that\'s simple! 😃 {smile}'
    }

    assert_equal "foo=こんにちは means hello, \"ようこそ\" means welcome, that's simple! 😃 {smile}\n", \
      Kamal::EnvFile.new(env).to_s
  end


Review comment (suggestion):
Can you change these to `#` instead of `\#`? They mean the same thing and the `\` makes it seem like there's some extra escaping going on that isn't really there.

Code after:
require "test_helper"

class EnvFileTest < ActiveSupport::TestCase
  test "to_s" do
    env = {
      "foo" => "bar",
      "baz" => "haz"
    }

    assert_equal "foo=bar\nbaz=haz\n", \
      Kamal::EnvFile.new(env).to_s
  end

  test "to_s won't escape '#'" do
    env = {
      "foo" => '#$foo',
      "bar" => '#{bar}'
    }

    assert_equal "foo=\#$foo\nbar=\#{bar}\n", \
      Kamal::EnvFile.new(env).to_s
  end

  test "to_str won't escape chinese characters" do
    env = {
      "foo" => '你好 means hello, "欢迎" means welcome, that\'s simple! 😃 {smile}'
    }

    assert_equal "foo=你好 means hello, \"欢迎\" means welcome, that's simple! 😃 {smile}\n",
      Kamal::EnvFile.new(env).to_s
  end

  test "to_s won't escape japanese characters" do
    env = {
      "foo" => 'こんにちは means hello, "ようこそ" means welcome, that\'s simple! 😃 {smile}'
    }

    assert_equal "foo=こんにちは means hello, \"ようこそ\" means welcome, that's simple! 😃 {smile}\n", \
      Kamal::EnvFile.new(env).to_s
  end
Repository: mrsked/mrsk
File: lib/kamal/configuration.rb (Ruby)

Code before:
  end


  def hooks_path
    raw_config.hooks_path || ".kamal/hooks"
  end

  def asset_path
    raw_config.asset_path
  end


  def env_tags
    @env_tags ||= if (tags = raw_config.env["tags"])
      tags.collect { |name, config| Env::Tag.new(name, config: config, secrets: secrets) }
    else
      []
    end
  end

  def env_tag(name)
    env_tags.detect { |t| t.name == name.to_s }
  end

  def proxy_publish_args(http_port, https_port, bind_ip = nil)
    bind_ip = bind_ip ? "#{bind_ip}:" : ""
    argumentize "--publish", [ "#{bind_ip}#{http_port}:#{PROXY_HTTP_PORT}", "#{bind_ip}#{https_port}:#{PROXY_HTTPS_PORT}" ]
  end

  def proxy_logging_args(max_size)
    argumentize "--log-opt", "max-size=#{max_size}" if max_size.present?
  end

  def proxy_options_default
    [ *proxy_publish_args(PROXY_HTTP_PORT, PROXY_HTTPS_PORT), *proxy_logging_args(PROXY_LOG_MAX_SIZE) ]
  end

  def proxy_image
    "basecamp/kamal-proxy:#{PROXY_MINIMUM_VERSION}"
  end

  def proxy_container_name
    "kamal-proxy"
  end

  def proxy_directory
    File.join run_directory, "proxy"
  end

  def proxy_options_file
    File.join proxy_directory, "options"

Review comment (suggestion):
We could do this as

```
publish_http = [bind_ip, http_port, PROXY_HTTP_PORT].compact.join(":")
publish_https = [bind_ip, https_port, PROXY_HTTPS_PORT].compact.join(":")
argumentize "--publish", [ publish_http, publish_https ]
```

Code after:
  end


  def hooks_path
    raw_config.hooks_path || ".kamal/hooks"
  end

  def asset_path
    raw_config.asset_path
  end


  def env_tags
    @env_tags ||= if (tags = raw_config.env["tags"])
      tags.collect { |name, config| Env::Tag.new(name, config: config, secrets: secrets) }
    else
      []
    end
  end

  def env_tag(name)
    env_tags.detect { |t| t.name == name.to_s }
  end

  def proxy_publish_args(http_port, https_port, bind_ips = nil)
    ensure_valid_bind_ips(bind_ips)

    (bind_ips || [ nil ]).map do |bind_ip|
      bind_ip = format_bind_ip(bind_ip)
      publish_http = [ bind_ip, http_port, PROXY_HTTP_PORT ].compact.join(":")
      publish_https = [ bind_ip, https_port, PROXY_HTTPS_PORT ].compact.join(":")

      argumentize "--publish", [ publish_http, publish_https ]
    end.join(" ")
  end

  def proxy_logging_args(max_size)
    argumentize "--log-opt", "max-size=#{max_size}" if max_size.present?
  end

  def proxy_options_default
    [ *proxy_publish_args(PROXY_HTTP_PORT, PROXY_HTTPS_PORT), *proxy_logging_args(PROXY_LOG_MAX_SIZE) ]
  end

  def proxy_image
    "basecamp/kamal-proxy:#{PROXY_MINIMUM_VERSION}"
  end

  def proxy_container_name
    "kamal-proxy"
  end
Repository: mrsked/mrsk
File: lib/kamal/commands/registry.rb (Ruby)

Code before:
class Kamal::Commands::Registry < Kamal::Commands::Base
  delegate :registry, to: :config

  def login
    docker :login,
      registry.server,
      "-u", sensitive(Kamal::Utils.escape_shell_value(registry.username)),
      "-p", sensitive(Kamal::Utils.escape_shell_value(registry.password))
  end

  def logout
    docker :logout, registry.server
  end
end


Review comment (suggestion):
```suggestion
  def login(registry_config: config.registry)
```

Code after:
class Kamal::Commands::Registry < Kamal::Commands::Base
  def login(registry_config: nil)
    registry_config ||= config.registry

    docker :login,
      registry_config.server,
      "-u", sensitive(Kamal::Utils.escape_shell_value(registry_config.username)),
      "-p", sensitive(Kamal::Utils.escape_shell_value(registry_config.password))
  end

  def logout(registry_config: nil)
    registry_config ||= config.registry

    docker :logout, registry_config.server
  end
end
Repository: mrsked/mrsk
File: lib/kamal/commands/registry.rb (Ruby)

Code before:
class Kamal::Commands::Registry < Kamal::Commands::Base
  delegate :registry, to: :config

  def login
    docker :login,
      registry.server,
      "-u", sensitive(Kamal::Utils.escape_shell_value(registry.username)),
      "-p", sensitive(Kamal::Utils.escape_shell_value(registry.password))
  end

  def logout
    docker :logout, registry.server
  end
end


Review comment (suggestion):
```suggestion
  def logout(registry_config: config.registry)
```

Code after:
class Kamal::Commands::Registry < Kamal::Commands::Base
  def login(registry_config: nil)
    registry_config ||= config.registry

    docker :login,
      registry_config.server,
      "-u", sensitive(Kamal::Utils.escape_shell_value(registry_config.username)),
      "-p", sensitive(Kamal::Utils.escape_shell_value(registry_config.password))
  end

  def logout(registry_config: nil)
    registry_config ||= config.registry

    docker :logout, registry_config.server
  end
end
Repository: mrsked/mrsk
File: lib/kamal/commands/builder/cloud.rb (Ruby)

Code before:
class Kamal::Commands::Builder::Cloud < Kamal::Commands::Builder::Base
  # Expects `driver` to be of format "cloud docker-org-name/builder-name"

  def create
    docker :buildx, :create, "--driver", driver
  end

  def remove
    docker :buildx, :rm, builder_name
  end

  private
    def builder_name
      docker_cloud_build_parts = driver.sub(/^cloud /, "").split("/")
      "cloud-#{docker_cloud_build_parts[0]}-#{docker_cloud_build_parts[1]}"
    end

    def inspect_buildx
      pipe \
        docker(:buildx, :inspect, builder_name),
        grep("-q", "Endpoint:.*cloud://.*")
    end
end


Review comment (suggestion):
```suggestion
      driver.gsub(/[ \/]/,"-")
```

Code after:
class Kamal::Commands::Builder::Cloud < Kamal::Commands::Builder::Base
  # Expects `driver` to be of format "cloud docker-org-name/builder-name"

  def create
    docker :buildx, :create, "--driver", driver
  end

  def remove
    docker :buildx, :rm, builder_name
  end

  private
    def builder_name
      driver.gsub(/[ \/]/, "-")
    end

    def inspect_buildx
      pipe \
        docker(:buildx, :inspect, builder_name),
        grep("-q", "Endpoint:.*cloud://.*")
    end
end
Repository: mrsked/mrsk
File: lib/kamal/configuration/ssh.rb (Ruby)

Code before:

  def port
    ssh_config.fetch("port", 22)
  end

  def proxy
    if (proxy = ssh_config["proxy"])
      Net::SSH::Proxy::Jump.new(proxy.include?("@") ? proxy : "root@#{proxy}")
    elsif (proxy_command = ssh_config["proxy_command"])
      Net::SSH::Proxy::Command.new(proxy_command)
    end
  end

  def keys_only
    ssh_config["keys_only"]
  end

  def keys
    ssh_config["keys"]
  end

  def key_data
    key_data = ssh_config["key_data"]
    return unless key_data

    key_data.map { |k| k.include?("-----BEGIN") ? k : secrets[k] }
  end

  def options
    { user: user, port: port, proxy: proxy, logger: logger, keepalive: true, keepalive_interval: 30, keys_only: keys_only, keys: keys, key_data: key_data }.compact
  end

  def to_h
    options.except(:logger).merge(log_level: log_level)
  end

  private
    def logger
      LOGGER.tap { |logger| logger.level = log_level }
    end

    def log_level
      ssh_config.fetch("log_level", :fatal)
    end
end


Review comment (bug):
```suggestion
    key_data.map { |k| resolve_key_data(k) }
```

then put in private
```ruby
def resolve_key_data(key_or_name)
      # Try to parse as an SSH key first, if fail, we go old way.
      begin
        OpenSSL::PKey::RSA.new(key_or_name)
       key_or_name
      rescue OpenSSL::PKey::RSAError, TypeError
        # If parsing fails, treat as secret name
        secrets[key_or_name]
      end
 end
 ```
 
 PS: openssl is already available by sshkit

Code after:

  def port
    ssh_config.fetch("port", 22)
  end

  def proxy
    if (proxy = ssh_config["proxy"])
      Net::SSH::Proxy::Jump.new(proxy.include?("@") ? proxy : "root@#{proxy}")
    elsif (proxy_command = ssh_config["proxy_command"])
      Net::SSH::Proxy::Command.new(proxy_command)
    end
  end

  def keys_only
    ssh_config["keys_only"]
  end

  def keys
    ssh_config["keys"]
  end

  def key_data
    key_data = ssh_config["key_data"]
    return unless key_data

    key_data.map do |k|
      if secrets.key?(k)
        secrets[k]
      else
        warn "Inline key_data usage is deprecated and will be removed in Kamal 3. Please store your key_data in a secret."
        k
      end
    end
  end

  def config
    ssh_config["config"]
  end

  def options
    { user: user, port: port, proxy: proxy, logger: logger, keepalive: true, keepalive_interval: 30, keys_only: keys_only, keys: keys, key_data: key_data, config: config  }.compact
  end

  def to_h
    options.except(:logger).merge(log_level: log_level)
  end

  private
    def logger
      LOGGER.tap { |logger| logger.level = log_level }
    end
Repository: nexus-xyz/nexus-zkvm
File: supernova/src/circuits/nova/pcd/compression/commitment_utils.rs (Rust)

Code before:
use ark_ec::CurveGroup;
use ark_spartan::{
    math::Math,
    polycommitments::{PCSKeys, PolyCommitmentScheme, VectorCommitmentScheme},
};
use ark_std::marker::PhantomData;

use crate::commitment::CommitmentScheme;

pub struct PolyVectorCommitment<G, PC>
where
    G: CurveGroup,
    PC: PolyCommitmentScheme<G>,
{
    _group: PhantomData<G>,
    _poly_commitment: PhantomData<PC>,
}

impl<G: CurveGroup, PC: PolyCommitmentScheme<G>> CommitmentScheme<G> for PolyVectorCommitment<G, PC>
where
    G: CurveGroup,
    PC::Commitment: Copy,
{
    type SetupAux = PC::SRS;
    type PP = PCSKeys<G, PC>;
    type Commitment = PC::Commitment;

    /// This function is just for testing purposes: in practice, we will need to
    /// load PC's SRS from a file.
    fn setup(n: usize, srs: &PC::SRS) -> Self::PP {
        PC::trim(srs, n.log_2())
    }

    fn commit(pp: &Self::PP, x: &[G::ScalarField]) -> Self::Commitment {
        <PC as VectorCommitmentScheme<G>>::commit(x, &pp.ck)
    }
}


Review comment (suggestion):
I believe we still have to carry these 2 bounds, as  we can't put it into `PC::Commitment` definition.

Code after:
use ark_ec::CurveGroup;
use ark_spartan::{
    math::Math,
    polycommitments::{PCSKeys, PolyCommitmentScheme, VectorCommitmentScheme},
};
use ark_std::marker::PhantomData;

use crate::commitment::CommitmentScheme;

pub struct PolyVectorCommitment<G, PC>
where
    G: CurveGroup,
    PC: PolyCommitmentScheme<G>,
{
    _group: PhantomData<G>,
    _poly_commitment: PhantomData<PC>,
}

impl<G: CurveGroup, PC: PolyCommitmentScheme<G>> CommitmentScheme<G> for PolyVectorCommitment<G, PC>
where
    G: CurveGroup,
    PC::Commitment: Copy + Into<G> + From<G>,
{
    type SetupAux = PC::SRS;
    type PP = PCSKeys<G, PC>;
    type Commitment = PC::Commitment;

    /// This function is just for testing purposes: in practice, we will need to
    /// load PC's SRS from a file.
    fn setup(n: usize, srs: &PC::SRS) -> Self::PP {
        PC::trim(srs, n.log_2())
    }

    fn commit(pp: &Self::PP, x: &[G::ScalarField]) -> Self::Commitment {
        <PC as VectorCommitmentScheme<G>>::commit(x, &pp.ck)
    }
}